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
|
STRICT = true
DEBUG = true
require 'zoetrope'
--require 'group'
require 'version'
--require 'wrap_tile'
require 'player'
GameView = View:extend {
gameStart = 0,
onNew = function (self)
self:loadLayers('data/map.lua')
self.focus = the.player
self:clampTo(self.bg)
self.mazes = {self.maze1, self.maze2}
--self.maze1:revive()
--self.maze2:die()
the.activeMaze = self.maze1
--the.interface = Group:new()
--self:add(the.interface)
self:switchMaze()
self.gameStart = love.timer.getMicroTime()
self.lastChange = love.timer.getMicroTime()
end,
onUpdate = function(self, dt)
if the.player.active and love.timer.getMicroTime() > self.lastChange + 10 then
-- switch maze
self:switchMaze()
end
the.activeMaze:collide(the.player)
-- for _, mirror in ipairs(the.mirrors.sprites) do
-- if not mirror.of then
-- print('mirror:' .. inspect(mirror))
-- error('mirror OF NOTHING')
-- end
-- end
end,
switchMaze = function(self)
the.activeMaze:die()
if the.activeMaze == self.maze1 then
the.activeMaze = self.maze2
else
the.activeMaze = self.maze1
end
the.activeMaze:revive()
self._fx = {0,0,0,0}
self.tween:start(self._fx, 4, 150, 10, 'quadIn')
self.lastChange = love.timer.getMicroTime()
end,
onEndFrame = function(self)
--the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2
--the.interface.translate.y = the.player.y - the.app.height / 2 + the.player.height / 2
end
}
MenuScreen = View:extend {
title = Text:new{text = "Press a key to start", font = 48, wordWrap = false},
--title = Tile:new{image = 'data/title.png', x = 0, y = 0},
onNew = function(self)
self:add(self.title)
self.title:centerAround(400, 200)
end,
onUpdate = function(self, elapsed)
if the.keys:allJustPressed() then
the.app.view = GameView:new()
end
end
}
the.app = App:new {
onRun = function (self)
print('Version: ' .. VERSION)
self.view = GameView:new()
if DEBUG then
self.console:watch('VERSION', 'VERSION')
-- 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
}
|