/ld26

To get this branch, use:
bzr branch http://9ix.org/bzr/ld26

« back to all changes in this revision

Viewing changes to player.lua

  • Committer: Josh C
  • Date: 2013-04-29 01:14:37 UTC
  • Revision ID: josh@9ix.org-20130429011437-wvn3k55nyedhftza
more forgiving transition

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Player = Tile:extend {
2
2
   image = 'data/player-null.png',
 
3
   minY = 0, maxY = 600,
 
4
   canMove = true,
3
5
   onNew = function(self)
4
6
              the.player = self
5
7
 
13
15
           end,
14
16
   onStartFrame = function(self)
15
17
                     local ms = self.movementScale
16
 
 
17
 
                     if the.keys:pressed('up') then
18
 
                        self.velocity.y = -100 * ms
19
 
                     elseif the.keys:pressed('down') then
20
 
                        self.velocity.y = 100 * ms
21
 
                     else
22
 
                        self.velocity.y = 0
 
18
                     if DEBUG and the.console.visible then
 
19
                        ms = ms * 4
23
20
                     end
24
21
 
25
 
                     if the.keys:pressed('right') then
26
 
                        self.velocity.x = 100 * ms
27
 
                     elseif the.keys:pressed('left') then
28
 
                        self.velocity.x = -100 * ms
29
 
                     else
30
 
                        self.velocity.x = 0
 
22
                     if self.canMove then
 
23
                        if the.keys:pressed('up') then
 
24
                           self.velocity.y = -100 * ms
 
25
                        elseif the.keys:pressed('down') then
 
26
                           self.velocity.y = 100 * ms
 
27
                        else
 
28
                           self.velocity.y = 0
 
29
                        end
 
30
 
 
31
                        if the.keys:pressed('right') then
 
32
                           self.velocity.x = 100 * ms
 
33
                        elseif the.keys:pressed('left') then
 
34
                           self.velocity.x = -100 * ms
 
35
                        else
 
36
                           self.velocity.x = 0
 
37
                        end
31
38
                     end
32
39
                  end,
33
40
   onUpdate = function(self, dt)