/ld26

To get this branch, use:
bzr branch /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
15 by Josh C
more transitions and collisions
16
                     if DEBUG and the.console.visible then
17
                        ms = ms * 4
18
                     end
10 by Josh C
scale movement with player size
19
5 by Josh C
load a level, move a player around
20
                     if the.keys:pressed('up') then
10 by Josh C
scale movement with player size
21
                        self.velocity.y = -100 * ms
5 by Josh C
load a level, move a player around
22
                     elseif the.keys:pressed('down') then
10 by Josh C
scale movement with player size
23
                        self.velocity.y = 100 * ms
5 by Josh C
load a level, move a player around
24
                     else
25
                        self.velocity.y = 0
26
                     end
27
28
                     if the.keys:pressed('right') then
10 by Josh C
scale movement with player size
29
                        self.velocity.x = 100 * ms
5 by Josh C
load a level, move a player around
30
                     elseif the.keys:pressed('left') then
10 by Josh C
scale movement with player size
31
                        self.velocity.x = -100 * ms
5 by Josh C
load a level, move a player around
32
                     else
33
                        self.velocity.x = 0
34
                     end
11 by Josh C
player min/maxY on a level
35
                  end,
12 by Josh C
area transitions
36
   onUpdate = function(self, dt)
37
                 self:collide(the.view)
38
              end,
11 by Josh C
player min/maxY on a level
39
   onEndFrame = function(self)
40
                   if self.y < self.minY then
41
                      self.y = self.minY
42
                   end
43
                   if self.y > self.maxY then
44
                      self.y = self.maxY
45
                   end
46
                end
5 by Josh C
load a level, move a player around
47
}