/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:
12
12
   sequences = {
13
13
      stand = { frames = { 1 }, fps = 1 },
14
14
      walk = { frames = { 2, 3 }, fps = 5 },
15
 
      jump = { frames = { 4 }, fps = 1 }
 
15
      jump = { frames = { 4 }, fps = 1 },
 
16
      climbLeft = { frames = { 5, 6 }, fps = 5 },
 
17
      climbRight = { frames = { 7, 8 }, fps = 5 }
16
18
   },
17
19
   collisions = {},
18
20
   onWall = false,
 
21
   leftWallAt = 0,
19
22
   onNew = function (self)
20
23
              self.velocity.y = 0
21
24
              self.maxVelocity.y = 400
81
84
                     if self.onWall then
82
85
                        self.acceleration.y = 0
83
86
 
 
87
                        if self.onWall == 'right' then
 
88
                           self:play('climbRight')
 
89
                        elseif self.onWall == 'left' then
 
90
                           self:play('climbLeft')
 
91
                        end
 
92
 
84
93
                        if the.keys:pressed('up') then
85
94
                           self.velocity.y = -200
86
 
                           self:play('stand')
87
95
                        elseif the.keys:pressed('down') then
88
96
                           self.velocity.y = 200
89
 
                           self:play('stand')
90
97
                        else
91
98
                           self.velocity.y = 0
92
 
                           self:play('stand')
 
99
                           self:freeze(self.sequences[self.currentName].frames[1])
93
100
                        end
94
101
                     end
95
102
 
96
103
                     if the.keys:pressed('left') then
97
104
                        self.velocity.x = -200
98
105
                        if self.onGround then self:play('walk') end
99
 
                        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
100
110
                     elseif the.keys:pressed('right') then
101
111
                        self.velocity.x = 200
102
112
                        if self.onGround then self:play('walk') end
103
 
                        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
104
117
                     else
105
 
                        if self.onGround then self:play('stand') end
106
118
                        if not self.onWall then
 
119
                           if self.onGround then self:play('stand') end
107
120
                           self.velocity.x = 0
108
121
                        end
109
122
                     end
110
123
 
111
 
                     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
112
127
                        self.velocity.y = -400
113
128
                        self.jumping = true
114
129
                     end