/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',
18 by Josh C
village, lake
3
   minY = 0, maxY = 600,
42 by Josh C
be moved
4
   canMove = true,
5 by Josh C
load a level, move a player around
5
   onNew = function(self)
9 by Josh C
levels hash, scale player
6
              the.player = self
7
8
              self.movementScale = self.height / 32
12 by Josh C
area transitions
9
              --print(self.movementScale)
9 by Josh C
levels hash, scale player
10
11
              --self.scale = self.scaleHeight / self.height
12
              --self.width = self.height * .826
13
              --self.width = self.width * self.scale
14
              --self:updateQuad()
5 by Josh C
load a level, move a player around
15
           end,
16
   onStartFrame = function(self)
10 by Josh C
scale movement with player size
17
                     local ms = self.movementScale
15 by Josh C
more transitions and collisions
18
                     if DEBUG and the.console.visible then
19
                        ms = ms * 4
20
                     end
10 by Josh C
scale movement with player size
21
42 by Josh C
be moved
22
                     if self.canMove then
23
                        if the.keys:pressed('up') then
24
                           self.velocity.y = -100 * ms
25
                        elseif the.keys:pressed('down') then
26
                           self.velocity.y = 100 * ms
27
                        else
28
                           self.velocity.y = 0
29
                        end
5 by Josh C
load a level, move a player around
30
42 by Josh C
be moved
31
                        if the.keys:pressed('right') then
32
                           self.velocity.x = 100 * ms
33
                        elseif the.keys:pressed('left') then
34
                           self.velocity.x = -100 * ms
35
                        else
36
                           self.velocity.x = 0
37
                        end
5 by Josh C
load a level, move a player around
38
                     end
11 by Josh C
player min/maxY on a level
39
                  end,
12 by Josh C
area transitions
40
   onUpdate = function(self, dt)
41
                 self:collide(the.view)
42
              end,
11 by Josh C
player min/maxY on a level
43
   onEndFrame = function(self)
44
                   if self.y < self.minY then
45
                      self.y = self.minY
46
                   end
47
                   if self.y > self.maxY then
48
                      self.y = self.maxY
49
                   end
50
                end
5 by Josh C
load a level, move a player around
51
}