/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-15 01:54:31 UTC
  • Revision ID: josh@9ix.org-20130315015431-torvm0zhbk1rvkn3
wall jump

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
   },
19
19
   collisions = {},
20
20
   onWall = false,
 
21
   leftWallAt = 0,
21
22
   onNew = function (self)
22
23
              self.velocity.y = 0
23
24
              self.maxVelocity.y = 400
102
103
                     if the.keys:pressed('left') then
103
104
                        self.velocity.x = -200
104
105
                        if self.onGround then self:play('walk') end
105
 
                        if self.onWall == 'right' then self.onWall = false end
 
106
                        if self.onWall == 'right' then
 
107
                           self.onWall = false
 
108
                           self.leftWallAt = love.timer.getTime()
 
109
                        end
106
110
                     elseif the.keys:pressed('right') then
107
111
                        self.velocity.x = 200
108
112
                        if self.onGround then self:play('walk') end
109
 
                        if self.onWall == 'left' then self.onWall = false end
 
113
                        if self.onWall == 'left' then
 
114
                           self.onWall = false
 
115
                           self.leftWallAt = love.timer.getTime()
 
116
                        end
110
117
                     else
111
118
                        if not self.onWall then
112
119
                           if self.onGround then self:play('stand') end
114
121
                        end
115
122
                     end
116
123
 
117
 
                     if the.keys:justPressed('up') and self.onGround then
 
124
                     if the.keys:justPressed('up') and
 
125
                      (self.onGround or
 
126
                       (love.timer.getTime() - self.leftWallAt < .1) ) then
118
127
                        self.velocity.y = -400
119
128
                        self.jumping = true
120
129
                     end