/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
94
95
96
97
98
STRICT = true
DEBUG = true

require 'zoetrope'
--inspect = require 'inspect'

--require 'sprite'
require 'version'

require 'player'
require 'transition'
require 'displacer'
require 'inventory'
require 'levels'
require 'items'
require 'troll'
require 'gatetrigger'

require 'svg_levels'

GameView = View:extend {
   onNew = function (self)
              --print('loading level: '..self.level)
              if not levels[self.level] then
                 error('no such level: '..self.level)
              end
              for _, obj in ipairs(levels[self.level].objects()) do
                 self:add(obj)
                 --if obj.gateup then print('ADDING GATEUP') end
              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(Fill:new{x=100,y=100,width=25,height=25,fill={255,255,255}})

              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 {
   level = 'shore', --default level
   onRun = function (self)
              print('Version: ' .. VERSION)
              self.view = GameView:new{level = self.level}
              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

              --the.inventory:add(Flag:new())
           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

function love.load(arg)
   if arg[2] then
      the.app.level = arg[2]
   end

   the.app:run()
end