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