/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-12 17:21:28 UTC
  • Revision ID: josh@9ix.org-20130312172128-l336vwqawo81c6sm
really easy version of knowing when we reached the top of a wall.  
similar to how we're doing onGround.

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