/zoeplat

To get this branch, use:
bzr branch http://9ix.org/bzr/zoeplat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
STRICT = true
DEBUG = true

require 'zoetrope'

TERM_VEL = 400

Player = Tile:extend {
   image = 'data/player.png',
   onNew = function (self)
              self.velocity.y = 0
           end,
   onUpdate = function (self)

                 self.velocity.x = 0
                 if self.velocity.y >= TERM_VEL then
                    self.velocity.y = TERM_VEL
                    self.acceleration.y = 0
                 else
                    self.acceleration.y = 800
                 end

                 if the.keys:pressed('left') then
                    self.velocity.x = -200
                 elseif the.keys:pressed('right') then
                    self.velocity.x = 200
                 end

                 if the.keys:justPressed('up') then
                    self.velocity.y = -400
                 end

              end
}

GameView = View:extend {
   onNew = function (self)
              self:loadLayers('data/map.lua')
              self.focus = the.player
              self:clampTo(self.map)
           end,

   onEndFrame = function (self, dt)
                   self.map:subdisplace(the.player)
                end
}

the.app = App:new {
   onRun = function (self)
              self.view = GameView:new()
           end,
   onUpdate = function (self, dt)
                 if the.keys:justPressed('escape') then
                    love.event.quit()
                 end
              end
}