/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 15:08:32 UTC
  • Revision ID: josh@9ix.org-20130312150832-ue1q4xuq4weypqc2
fairly major overhaul of collision handling to track whether we're on a 
wall.  also monkey patch Sprite to displace on only one axis

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
                        self:play('jump')
77
77
                     end
78
78
 
 
79
                     self.velocity.x = 0
79
80
                     self.acceleration.y = 800
80
81
 
81
82
                     if self.onWall then
97
98
                        self.velocity.x = -200
98
99
                        if self.onGround then self:play('walk') end
99
100
                        if self.onWall == 'right' then self.onWall = false end
 
101
                        if self.onWall == 'right' then self.onWall = false end
100
102
                     elseif the.keys:pressed('right') then
101
103
                        self.velocity.x = 200
102
104
                        if self.onGround then self:play('walk') end
103
105
                        if self.onWall == 'left' then self.onWall = false end
104
106
                     else
105
107
                        if self.onGround then self:play('stand') end
106
 
                        if not self.onWall then
107
 
                           self.velocity.x = 0
108
 
                        end
109
108
                     end
110
109
 
111
110
                     if the.keys:justPressed('up') and self.onGround then
120
119
               self:collide(the.view.map)
121
120
 
122
121
               -- handle X collisions
123
 
               self.onWall = false
124
122
               for _, col in ipairs(self.collisions) do
125
123
                  col.other:displaceDir(self, 'x')
126
124
                  if self.velocity.x > 0 then