/ld26

To get this branch, use:
bzr branch http://9ix.org/bzr/ld26
5 by Josh C
load a level, move a player around
1
Player = Tile:extend {
9 by Josh C
levels hash, scale player
2
   image = 'data/player-null.png',
5 by Josh C
load a level, move a player around
3
   onNew = function(self)
9 by Josh C
levels hash, scale player
4
              the.player = self
5
6
              self.movementScale = self.height / 32
12 by Josh C
area transitions
7
              --print(self.movementScale)
9 by Josh C
levels hash, scale player
8
9
              --self.scale = self.scaleHeight / self.height
10
              --self.width = self.height * .826
11
              --self.width = self.width * self.scale
12
              --self:updateQuad()
5 by Josh C
load a level, move a player around
13
           end,
14
   onStartFrame = function(self)
10 by Josh C
scale movement with player size
15
                     local ms = self.movementScale
16
5 by Josh C
load a level, move a player around
17
                     if the.keys:pressed('up') then
10 by Josh C
scale movement with player size
18
                        self.velocity.y = -100 * ms
5 by Josh C
load a level, move a player around
19
                     elseif the.keys:pressed('down') then
10 by Josh C
scale movement with player size
20
                        self.velocity.y = 100 * ms
5 by Josh C
load a level, move a player around
21
                     else
22
                        self.velocity.y = 0
23
                     end
24
25
                     if the.keys:pressed('right') then
10 by Josh C
scale movement with player size
26
                        self.velocity.x = 100 * ms
5 by Josh C
load a level, move a player around
27
                     elseif the.keys:pressed('left') then
10 by Josh C
scale movement with player size
28
                        self.velocity.x = -100 * ms
5 by Josh C
load a level, move a player around
29
                     else
30
                        self.velocity.x = 0
31
                     end
11 by Josh C
player min/maxY on a level
32
                  end,
12 by Josh C
area transitions
33
   onUpdate = function(self, dt)
34
                 self:collide(the.view)
35
              end,
11 by Josh C
player min/maxY on a level
36
   onEndFrame = function(self)
37
                   if self.y < self.minY then
38
                      self.y = self.minY
39
                   end
40
                   if self.y > self.maxY then
41
                      self.y = self.maxY
42
                   end
43
                end
5 by Josh C
load a level, move a player around
44
}