/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:48:42 UTC
  • Revision ID: josh@9ix.org-20130312174842-co8zn0hy0v6u18qf
climbing animation

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,
76
78
                        self:play('jump')
77
79
                     end
78
80
 
79
 
                     self.velocity.x = 0
80
81
                     self.acceleration.y = 800
81
82
 
82
83
                     if self.onWall then
83
84
                        self.acceleration.y = 0
84
85
 
 
86
                        if self.onWall == 'right' then
 
87
                           self:play('climbRight')
 
88
                        elseif self.onWall == 'left' then
 
89
                           self:play('climbLeft')
 
90
                        end
 
91
 
85
92
                        if the.keys:pressed('up') then
86
93
                           self.velocity.y = -200
87
 
                           self:play('stand')
88
94
                        elseif the.keys:pressed('down') then
89
95
                           self.velocity.y = 200
90
 
                           self:play('stand')
91
96
                        else
92
97
                           self.velocity.y = 0
93
 
                           self:play('stand')
 
98
                           self:freeze(self.sequences[self.currentName].frames[1])
94
99
                        end
95
100
                     end
96
101
 
98
103
                        self.velocity.x = -200
99
104
                        if self.onGround then self:play('walk') end
100
105
                        if self.onWall == 'right' then self.onWall = false end
101
 
                        if self.onWall == 'right' then self.onWall = false end
102
106
                     elseif the.keys:pressed('right') then
103
107
                        self.velocity.x = 200
104
108
                        if self.onGround then self:play('walk') end
105
109
                        if self.onWall == 'left' then self.onWall = false end
106
110
                     else
107
 
                        if self.onGround then self:play('stand') end
 
111
                        if not self.onWall then
 
112
                           if self.onGround then self:play('stand') end
 
113
                           self.velocity.x = 0
 
114
                        end
108
115
                     end
109
116
 
110
117
                     if the.keys:justPressed('up') and self.onGround then
119
126
               self:collide(the.view.map)
120
127
 
121
128
               -- handle X collisions
 
129
               self.onWall = false
122
130
               for _, col in ipairs(self.collisions) do
123
131
                  col.other:displaceDir(self, 'x')
124
132
                  if self.velocity.x > 0 then