/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-27 18:35:29 UTC
  • Revision ID: josh@9ix.org-20130427183529-0lqp56qq6m0yocn1
levels hash, scale player

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