/ld27

To get this branch, use:
bzr branch http://9ix.org/bzr/ld27
3 by Josh C
map loading, super basic movement
1
local velLimit = 400
2
Player = Tile:extend{
3
   image = 'data/player.png',
4
   maxVelocity = {x=velLimit,y=velLimit},
5
   minVelocity = {x=-velLimit, y=-velLimit},
19 by Josh C
separate collision box for player so it can scale
6
   onNew = function(self)
7
              self.collider = PlayerCollider:new()
8
              the.view:add(self.collider)
9
           end,
3 by Josh C
map loading, super basic movement
10
   onStartFrame = function(self)
11
                     if the.keys:pressed('left') then
9 by Josh C
3rd maze... reverse
12
                        self.velocity.x = -200 * the.activeMaze.moveMod
3 by Josh C
map loading, super basic movement
13
                     elseif the.keys:pressed('right') then
9 by Josh C
3rd maze... reverse
14
                        self.velocity.x = 200 * the.activeMaze.moveMod
3 by Josh C
map loading, super basic movement
15
                     else
16
                        self.velocity.x = 0
17
                     end
18
19
                     if the.keys:pressed('up') then
9 by Josh C
3rd maze... reverse
20
                        self.velocity.y = -200 * the.activeMaze.moveMod
3 by Josh C
map loading, super basic movement
21
                     elseif the.keys:pressed('down') then
9 by Josh C
3rd maze... reverse
22
                        self.velocity.y = 200 * the.activeMaze.moveMod
3 by Josh C
map loading, super basic movement
23
                     else
24
                        self.velocity.y = 0
25
                     end
26
                  end,
19 by Josh C
separate collision box for player so it can scale
27
   onUpdate = function(self, dt)
28
                 self.collider.x = self.x + self.width / 2 * (1 - self.scale)
29
                 self.collider.y = self.y + self.height / 2 * (1 - self.scale)
30
              end,
31
}
32
33
PlayerCollider = Fill:extend{
34
   fill = {0,0,255},
35
   onUpdate = function(self, dt)
36
                 self.visible = DEBUG and the.console.visible
37
              end,
3 by Josh C
map loading, super basic movement
38
   onCollide = function(self, other)
19 by Josh C
separate collision box for player so it can scale
39
                  local p = the.player
40
3 by Josh C
map loading, super basic movement
41
                  other:displace(self)
19 by Josh C
separate collision box for player so it can scale
42
                  p.x = self.x - p.width / 2 * (1 - p.scale)
43
                  p.y = self.y - p.height / 2 * (1 - p.scale)
3 by Josh C
map loading, super basic movement
44
               end
45
}