/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-28 18:01:54 UTC
  • Revision ID: josh@9ix.org-20130428180154-k9g0f2yxrm4fheul
level tweaks & fixes

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,
3
4
   onNew = function(self)
4
5
              the.player = self
5
6
 
6
7
              self.movementScale = self.height / 32
 
8
              --print(self.movementScale)
7
9
 
8
10
              --self.scale = self.scaleHeight / self.height
9
11
              --self.width = self.height * .826
11
13
              --self:updateQuad()
12
14
           end,
13
15
   onStartFrame = function(self)
 
16
                     local ms = self.movementScale
 
17
                     if DEBUG and the.console.visible then
 
18
                        ms = ms * 4
 
19
                     end
 
20
 
14
21
                     if the.keys:pressed('up') then
15
 
                        self.velocity.y = -100
 
22
                        self.velocity.y = -100 * ms
16
23
                     elseif the.keys:pressed('down') then
17
 
                        self.velocity.y = 100
 
24
                        self.velocity.y = 100 * ms
18
25
                     else
19
26
                        self.velocity.y = 0
20
27
                     end
21
28
 
22
29
                     if the.keys:pressed('right') then
23
 
                        self.velocity.x = 100
 
30
                        self.velocity.x = 100 * ms
24
31
                     elseif the.keys:pressed('left') then
25
 
                        self.velocity.x = -100
 
32
                        self.velocity.x = -100 * ms
26
33
                     else
27
34
                        self.velocity.x = 0
28
35
                     end
29
 
                  end
 
36
                  end,
 
37
   onUpdate = function(self, dt)
 
38
                 self:collide(the.view)
 
39
              end,
 
40
   onEndFrame = function(self)
 
41
                   if self.y < self.minY then
 
42
                      self.y = self.minY
 
43
                   end
 
44
                   if self.y > self.maxY then
 
45
                      self.y = self.maxY
 
46
                   end
 
47
                end
30
48
}
 
 
b'\\ No newline at end of file'