/zoeplat

To get this branch, use:
bzr branch http://9ix.org/bzr/zoeplat
2 by Josh C
basic tiles, map, player, movement
1
STRICT = true
2
DEBUG = true
3
4
require 'zoetrope'
5
3 by Josh C
jump
6
TERM_VEL = 400
7
2 by Josh C
basic tiles, map, player, movement
8
Player = Tile:extend {
9
   image = 'data/player.png',
3 by Josh C
jump
10
   onNew = function (self)
11
              self.velocity.y = 0
12
           end,
2 by Josh C
basic tiles, map, player, movement
13
   onUpdate = function (self)
3 by Josh C
jump
14
2 by Josh C
basic tiles, map, player, movement
15
                 self.velocity.x = 0
3 by Josh C
jump
16
                 if self.velocity.y >= TERM_VEL then
17
                    self.velocity.y = TERM_VEL
18
                    self.acceleration.y = 0
19
                 else
20
                    self.acceleration.y = 800
21
                 end
2 by Josh C
basic tiles, map, player, movement
22
23
                 if the.keys:pressed('left') then
24
                    self.velocity.x = -200
25
                 elseif the.keys:pressed('right') then
26
                    self.velocity.x = 200
27
                 end
3 by Josh C
jump
28
29
                 if the.keys:justPressed('up') then
30
                    self.velocity.y = -400
31
                 end
32
2 by Josh C
basic tiles, map, player, movement
33
              end
34
}
35
36
GameView = View:extend {
37
   onNew = function (self)
38
              self:loadLayers('data/map.lua')
39
              self.focus = the.player
40
              self:clampTo(self.map)
41
           end,
42
3 by Josh C
jump
43
   onEndFrame = function (self, dt)
44
                   self.map:subdisplace(the.player)
45
                end
2 by Josh C
basic tiles, map, player, movement
46
}
47
48
the.app = App:new {
49
   onRun = function (self)
50
              self.view = GameView:new()
51
           end,
52
   onUpdate = function (self, dt)
53
                 if the.keys:justPressed('escape') then
54
                    love.event.quit()
55
                 end
56
              end
57
}