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 |
|
4
by Josh C
switch mazes |
17 |
self:clampTo(self.bg) |
18 |
||
19 |
self.mazes = {self.maze1, self.maze2} |
|
5
by Josh C
fade in to let you know change is coming |
20 |
--self.maze1:revive() |
21 |
--self.maze2:die() |
|
4
by Josh C
switch mazes |
22 |
the.activeMaze = self.maze1 |
3
by Josh C
map loading, super basic movement |
23 |
|
24 |
--the.interface = Group:new() |
|
25 |
||
26 |
--self:add(the.interface) |
|
27 |
||
5
by Josh C
fade in to let you know change is coming |
28 |
self:switchMaze() |
29 |
||
4
by Josh C
switch mazes |
30 |
self.gameStart = love.timer.getMicroTime() |
31 |
self.lastChange = love.timer.getMicroTime() |
|
3
by Josh C
map loading, super basic movement |
32 |
end, |
33 |
onUpdate = function(self, dt) |
|
4
by Josh C
switch mazes |
34 |
if the.player.active and love.timer.getMicroTime() > self.lastChange + 10 then |
3
by Josh C
map loading, super basic movement |
35 |
-- switch maze |
5
by Josh C
fade in to let you know change is coming |
36 |
self:switchMaze() |
3
by Josh C
map loading, super basic movement |
37 |
end |
38 |
||
4
by Josh C
switch mazes |
39 |
the.activeMaze:collide(the.player) |
40 |
||
41 |
||
3
by Josh C
map loading, super basic movement |
42 |
-- for _, mirror in ipairs(the.mirrors.sprites) do |
43 |
-- if not mirror.of then |
|
44 |
-- print('mirror:' .. inspect(mirror)) |
|
45 |
-- error('mirror OF NOTHING') |
|
46 |
-- end |
|
47 |
-- end |
|
48 |
end, |
|
5
by Josh C
fade in to let you know change is coming |
49 |
switchMaze = function(self) |
50 |
the.activeMaze:die() |
|
51 |
if the.activeMaze == self.maze1 then |
|
52 |
the.activeMaze = self.maze2 |
|
53 |
else |
|
54 |
the.activeMaze = self.maze1 |
|
55 |
end |
|
56 |
the.activeMaze:revive() |
|
57 |
||
58 |
self._fx = {255,255,255,0} |
|
59 |
self.tween:start(self._fx, 4, 150, 10, 'quadIn') |
|
60 |
||
61 |
self.lastChange = love.timer.getMicroTime() |
|
62 |
end, |
|
3
by Josh C
map loading, super basic movement |
63 |
onEndFrame = function(self) |
64 |
--the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2 |
|
65 |
--the.interface.translate.y = the.player.y - the.app.height / 2 + the.player.height / 2 |
|
66 |
end |
|
67 |
} |
|
68 |
||
69 |
MenuScreen = View:extend { |
|
70 |
title = Text:new{text = "Press a key to start", font = 48, wordWrap = false}, |
|
71 |
--title = Tile:new{image = 'data/title.png', x = 0, y = 0}, |
|
72 |
onNew = function(self) |
|
73 |
self:add(self.title) |
|
74 |
self.title:centerAround(400, 200) |
|
75 |
end, |
|
76 |
onUpdate = function(self, elapsed) |
|
77 |
if the.keys:allJustPressed() then |
|
78 |
the.app.view = GameView:new() |
|
79 |
end |
|
80 |
end |
|
81 |
} |
|
82 |
||
83 |
the.app = App:new { |
|
84 |
onRun = function (self) |
|
85 |
print('Version: ' .. VERSION) |
|
86 |
||
87 |
self.view = GameView:new() |
|
88 |
||
89 |
if DEBUG then |
|
90 |
self.console:watch('VERSION', 'VERSION') |
|
91 |
||
92 |
-- back off that dark overlay a bit |
|
93 |
self.console.fill.fill[4] = 75 |
|
94 |
end |
|
95 |
end, |
|
96 |
onUpdate = function (self, dt) |
|
97 |
if the.keys:justPressed('escape') then |
|
98 |
self.quit() |
|
99 |
end |
|
100 |
end |
|
101 |
} |