/ld26

To get this branch, use:
bzr branch http://9ix.org/bzr/ld26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Player = Tile:extend {
   image = 'data/player-null.png',
   minY = 0, maxY = 600,
   canMove = true,
   onNew = function(self)
              the.player = self

              self.movementScale = self.height / 32
              --print(self.movementScale)

              --self.scale = self.scaleHeight / self.height
              --self.width = self.height * .826
              --self.width = self.width * self.scale
              --self:updateQuad()
           end,
   onStartFrame = function(self)
                     local ms = self.movementScale
                     if DEBUG and the.console.visible then
                        ms = ms * 4
                     end

                     if self.canMove then
                        if the.keys:pressed('up') then
                           self.velocity.y = -100 * ms
                        elseif the.keys:pressed('down') then
                           self.velocity.y = 100 * ms
                        else
                           self.velocity.y = 0
                        end

                        if the.keys:pressed('right') then
                           self.velocity.x = 100 * ms
                        elseif the.keys:pressed('left') then
                           self.velocity.x = -100 * ms
                        else
                           self.velocity.x = 0
                        end
                     end
                  end,
   onUpdate = function(self, dt)
                 self:collide(the.view)
              end,
   onEndFrame = function(self)
                   if self.y < self.minY then
                      self.y = self.minY
                   end
                   if self.y > self.maxY then
                      self.y = self.maxY
                   end
                end
}