/ld26

To get this branch, use:
bzr branch http://9ix.org/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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
STRICT = true
DEBUG = true

require 'zoetrope'

--require 'sprite'
require 'version'

require 'player'
require 'transition'
require 'displacer'
require 'inventory'
require 'flower'

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,
   },
   foresthut = {
      objects = function() return {
                      Tile:new{image = 'data/foresthut-bg.png'},
                      Player:new{x = 745, y = 430,
                                 image = 'data/forest1-player.png'},
                      Tile:new{image = 'data/foresthut-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
   },
   lake = {
      objects = function() return {
                      Tile:new{image = 'data/lake-bg.png'},
                      Player:new{x = 540, y = 266,
                                 image = 'data/lake-player.png'},
                   }
                end
   },
   village = {
      objects = function() return {
                      Tile:new{image = 'data/village-bg.png'},
                      Player:new{x = 121, y = 440,
                                 image = 'data/village-player.png'},
                   }
                end
   },
   bridge = {
      objects = function() return {
                      Tile:new{image = 'data/bridge-bg.png'},
                      Player:new{x = 121, y = 440,
                                 image = 'data/bridge-player.png'},
                      Tile:new{image = 'data/bridge-fg.png'}
                   }
                end
   }
}

GameView = View:extend {
   level = 'shore', --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
                 if not the.inventory.items[obj.name] then
                    self:add(obj)
                 end
              end

              self:add(the.inventory)

              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)
              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
}

-- for accessing from debug console
function l(level)
   the.app.view = GameView:new{level = level}
end