/zoeplat

To get this branch, use:
bzr branch http://9ix.org/bzr/zoeplat

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-03-16 19:10:33 UTC
  • Revision ID: josh@9ix.org-20130316191033-o1qwl2zy3ps020y2
buildĀ moreĀ level

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
require 'zoetrope'
5
5
__ = require 'underscore'
6
6
--inspect = require 'inspect'
 
7
require 'pepperprof'
7
8
 
8
9
Player = Animation:extend {
9
10
   image = 'data/player.png',
18
19
   },
19
20
   collisions = {},
20
21
   onWall = false,
 
22
   leftWallAt = 0,
21
23
   onNew = function (self)
22
24
              self.velocity.y = 0
23
25
              self.maxVelocity.y = 400
102
104
                     if the.keys:pressed('left') then
103
105
                        self.velocity.x = -200
104
106
                        if self.onGround then self:play('walk') end
105
 
                        if self.onWall == 'right' then self.onWall = false end
 
107
                        if self.onWall == 'right' then
 
108
                           self.onWall = false
 
109
                           self.leftWallAt = love.timer.getTime()
 
110
                        end
106
111
                     elseif the.keys:pressed('right') then
107
112
                        self.velocity.x = 200
108
113
                        if self.onGround then self:play('walk') end
109
 
                        if self.onWall == 'left' then self.onWall = false end
 
114
                        if self.onWall == 'left' then
 
115
                           self.onWall = false
 
116
                           self.leftWallAt = love.timer.getTime()
 
117
                        end
110
118
                     else
111
119
                        if not self.onWall then
112
120
                           if self.onGround then self:play('stand') end
114
122
                        end
115
123
                     end
116
124
 
117
 
                     if the.keys:justPressed('up') and self.onGround then
 
125
                     if the.keys:justPressed('up') and
 
126
                      (self.onGround or the.console.visible or
 
127
                       (love.timer.getTime() - self.leftWallAt < .1) ) then
118
128
                        self.velocity.y = -400
119
129
                        self.jumping = true
120
130
                     end
223
233
              self.view = GameView:new()
224
234
              self.console:watch('onGround', 'the.player.onGround')
225
235
              self.console:watch('onWall', 'the.player.onWall')
 
236
              self.console:watch('updateTook', 'the.updateTook')
 
237
              self.console:watch('drawTook', 'the.drawTook')
 
238
 
 
239
              --the.profiler = newProfiler('time', 2000)
 
240
              --the.profiler = newProfiler()
 
241
              --the.profiler:start()
226
242
           end,
227
243
   onUpdate = function (self, dt)
228
 
                 if the.keys:justPressed('escape') and 
229
 
                   not self.console.visible then
 
244
                 if the.keys:justPressed('escape') then
 
245
                    if the.profiler then
 
246
                       the.profiler:stop()
 
247
                       local outfile = io.open( "profile.txt", "w+" )
 
248
                       the.profiler:report( outfile )
 
249
                       outfile:close()
 
250
                    end
 
251
 
230
252
                    self.quit()
231
253
                 end
232
 
              end
233
 
}
 
 
b'\\ No newline at end of file'
 
254
              end,
 
255
   update = function (self, dt)
 
256
               the.updateStart = love.timer.getMicroTime()
 
257
               App.update(self, dt)
 
258
               if the.updateStart then
 
259
                  the.updateTook = love.timer.getMicroTime() - the.updateStart
 
260
               end
 
261
            end
 
262
}