/ld26

To get this branch, use:
bzr branch /bzr/ld26

« back to all changes in this revision

Viewing changes to player.lua

  • Committer: Josh C
  • Date: 2013-04-27 22:53:39 UTC
  • Revision ID: josh@9ix.org-20130427225339-6b4me5c8wi7y3jl0
pull data from svg to place objects into the world

Show diffs side-by-side

added added

removed removed

1
1
Player = Tile:extend {
2
2
   image = 'data/player-null.png',
3
 
   minY = 0, maxY = 600,
4
 
   canMove = true,
5
3
   onNew = function(self)
6
4
              the.player = self
7
5
 
15
13
           end,
16
14
   onStartFrame = function(self)
17
15
                     local ms = self.movementScale
18
 
                     if DEBUG and the.console.visible then
19
 
                        ms = ms * 4
 
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
20
23
                     end
21
24
 
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
 
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
38
31
                     end
39
32
                  end,
40
33
   onUpdate = function(self, dt)