/ld27

To get this branch, use:
bzr branch http://9ix.org/bzr/ld27
3 by Josh C
map loading, super basic movement
1
STRICT = true
2
DEBUG = true
3
4
require 'zoetrope'
5
6
--require 'group'
7
8
require 'version'
9
--require 'wrap_tile'
10
require 'player'
11
12
GameView = View:extend {
13
   gameStart = 0,
14
   onNew = function (self)
15
              self:loadLayers('data/map.lua')
16
              self.focus = the.player
17
              self:clampTo(self.map)
18
19
              --the.interface = Group:new()
20
21
              --self:add(the.interface)
22
23
              self.gameStart = love.timer.getTime()
24
              self.lastChange = love.timer.getTime()
25
           end,
26
   onUpdate = function(self, dt)
27
                 if the.player.active and love.timer.getTime() > self.lastChange + 10 then
28
                    -- switch maze
29
30
                    self.lastChange = love.timer.getTime()
31
                 end
32
33
                 -- for _, mirror in ipairs(the.mirrors.sprites) do
34
                 --    if not mirror.of then
35
                 --       print('mirror:' .. inspect(mirror))
36
                 --       error('mirror OF NOTHING')
37
                 --    end
38
                 -- end
39
              end,
40
   onEndFrame = function(self)
41
                   --the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2
42
                   --the.interface.translate.y = the.player.y - the.app.height / 2 + the.player.height / 2
43
                end
44
}
45
46
MenuScreen = View:extend {
47
   title = Text:new{text = "Press a key to start", font = 48, wordWrap = false},
48
   --title = Tile:new{image = 'data/title.png', x = 0, y = 0},
49
   onNew = function(self)
50
              self:add(self.title)
51
              self.title:centerAround(400, 200)
52
           end,
53
   onUpdate = function(self, elapsed)
54
                 if the.keys:allJustPressed() then
55
                    the.app.view = GameView:new()
56
                 end
57
              end
58
}
59
60
the.app = App:new {
61
   onRun = function (self)
62
              print('Version: ' .. VERSION)
63
64
              self.view = GameView:new()
65
66
              if DEBUG then
67
                 self.console:watch('VERSION', 'VERSION')
68
69
                 -- back off that dark overlay a bit
70
                 self.console.fill.fill[4] = 75
71
              end
72
           end,
73
   onUpdate = function (self, dt)
74
                 if the.keys:justPressed('escape') then
75
                    self.quit()
76
                 end
77
              end
78
}