/ld26

To get this branch, use:
bzr branch /bzr/ld26
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
STRICT = true
DEBUG = true

require 'zoetrope'

--require 'sprite'
require 'version'

require 'player'
require 'transition'
require 'displacer'
require 'svg_levels'

levels = {
   forest1 = {
      objects = function() return {
                      Tile:new{image = 'data/forest1-bg.png'},
                      Player:new{x = 200, y = 380,
                                 minY = 330, maxY = 500,
                                 image = 'data/forest1-player.png'},
                      Tile:new{image = 'data/forest1-fg.png'}
                   } end,
   },
   shore = {
      objects = function() return {
                      Tile:new{image = 'data/shore-bg.png'},
                      Player:new{x = 145, y = 133,
                                 minY = 133, maxY = 133,
                                 image = 'data/shore-player.png'},
                      Tile:new{image = 'data/shore-fg.png'},
                      Transition:new{x = 10, y = 133, target = 'forest1',
                                     targetX = 735, targetY = 370}
                   } end
   }
}

GameView = View:extend {
   level = 'forest1', --default level
   onNew = function (self)
              --print('loading level: '..self.level)
              for _, obj in ipairs(levels[self.level].objects()) do
                 self:add(obj)
              end
              for _, obj in ipairs(svg_objects[self.level]) do
                 self:add(obj)
              end

              self:flash({0,0,0})

              --self.focus = the.player
              --self:clampTo(self.map)
           end,
   draw = function (self, x, y)
             View.draw(self, x, y)
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
             love.graphics.print('version:' .. VERSION, 20, 570)
          end,
   onUpdate = function (self, dt)
                 if the.keys:justPressed('a') then
                    the.app.view = GameView:new{level = 'forest1'}
                 elseif the.keys:justPressed('b') then
                    the.app.view = GameView:new{level = 'shore'}
                 end
              end
}

the.app = App:new {
   onRun = function (self)
              self.view = GameView:new()
              if DEBUG then
                 self.console:watch('VERSION', 'VERSION')
                 self.console:watch('updateTook', 'the.updateTook')
                 self.console:watch('view.tween.status', 'the.app.view.tween.status()')
                 self.console:watch('view.tween.active', 'the.app.view.tween.active')
                 --self.console:watch('drawTook', 'the.drawTook')

                 -- back off that dark overlay a bit
                 self.console.fill.fill[4] = 75
              end
           end,
   onUpdate = function (self, dt)
                 if the.keys:justPressed('escape') then
                    self.quit()
                 end
              end,
   update = function (self, dt)
               the.updateStart = love.timer.getMicroTime()
               App.update(self, dt)
               if the.updateStart then
                  the.updateTook = love.timer.getMicroTime() - the.updateStart
               end
            end
}