bzr branch
http://9ix.org/bzr/ld28
2
by Josh C
basic delayed movement |
1 |
STRICT = true |
2 |
DEBUG = true |
|
3 |
||
4 |
require 'zoetrope' |
|
5 |
deque = require 'deque' |
|
10
by Josh C
collide w/ the map |
6 |
--inspect = require 'inspect' |
7 |
require 'sprite' |
|
2
by Josh C
basic delayed movement |
8 |
|
10
by Josh C
collide w/ the map |
9 |
require 'util' |
2
by Josh C
basic delayed movement |
10 |
require 'version' |
11 |
require 'player' |
|
7
by Josh C
rename NotPlayer to Clone cuz they're clones, and it's way too early |
12 |
require 'clone' |
15
by Josh C
put some walls and a goal... doesn't feel quite right. |
13 |
require 'goal' |
16
by Josh C
moving goal, clones turning green... |
14 |
require 'goal_person' |
15 |
||
16 |
dirs = {'left', 'right', 'up', 'down'} |
|
2
by Josh C
basic delayed movement |
17 |
|
18 |
GameView = View:extend { |
|
19 |
onNew = function (self) |
|
10
by Josh C
collide w/ the map |
20 |
self:loadLayers('data/map.lua') |
2
by Josh C
basic delayed movement |
21 |
|
13
by Josh C
align to grid |
22 |
local tw = math.floor(the.app.width / 16) |
23 |
local th = math.floor(the.app.height / 16) |
|
24 |
||
3
by Josh C
add a couple other clones that move randomly |
25 |
the.player = Player:new{ |
13
by Josh C
align to grid |
26 |
x = math.random(2, tw-2) * 16, |
27 |
y = math.random(2, th-2) * 16 |
|
3
by Josh C
add a couple other clones that move randomly |
28 |
} |
2
by Josh C
basic delayed movement |
29 |
self:add(the.player) |
3
by Josh C
add a couple other clones that move randomly |
30 |
|
16
by Josh C
moving goal, clones turning green... |
31 |
the.goalPerson = GoalPerson:new{ |
32 |
x = math.random(2, tw-2) * 16, |
|
33 |
y = math.random(2, th-2) * 16 |
|
34 |
} |
|
35 |
self:add(the.goalPerson) |
|
36 |
||
7
by Josh C
rename NotPlayer to Clone cuz they're clones, and it's way too early |
37 |
the.clones = Group:new() |
38 |
self:add(the.clones) |
|
14
by Josh C
16 is a more fun number. :D |
39 |
for _ = 1, 15 do |
7
by Josh C
rename NotPlayer to Clone cuz they're clones, and it's way too early |
40 |
the.clones:add(Clone:new { |
13
by Josh C
align to grid |
41 |
x = math.random(2, tw-2) * 16, |
42 |
y = math.random(2, th-2) * 16 |
|
43 |
}) |
|
3
by Josh C
add a couple other clones that move randomly |
44 |
end |
24
by Josh C
intermidiate + win screens |
45 |
|
27
by Josh C
R = restart level |
46 |
if self.level == 3 then |
47 |
self:add(Text:new{ |
|
48 |
text = "R = Restart level", |
|
49 |
x = 20, y = 20, |
|
50 |
width = 200 |
|
51 |
}) |
|
52 |
end |
|
53 |
||
24
by Josh C
intermidiate + win screens |
54 |
if self.level ~= 1 then |
55 |
self:flash({0,0,0}) |
|
56 |
end |
|
2
by Josh C
basic delayed movement |
57 |
end, |
58 |
onUpdate = function(self, dt) |
|
3
by Josh C
add a couple other clones that move randomly |
59 |
if the.player.moved then |
21
by Josh C
super hacky fix for passing through clones/goals |
60 |
the.clones:collide(the.player) |
61 |
the.goalPerson:collide(the.player) |
|
62 |
||
23
by Josh C
levels. ish. |
63 |
if self.level ~= 2 then |
64 |
the.goalPerson:doMove() |
|
65 |
end |
|
16
by Josh C
moving goal, clones turning green... |
66 |
|
7
by Josh C
rename NotPlayer to Clone cuz they're clones, and it's way too early |
67 |
for _, np in ipairs(the.clones.sprites) do |
3
by Josh C
add a couple other clones that move randomly |
68 |
np:doMove() |
69 |
end |
|
70 |
||
21
by Josh C
super hacky fix for passing through clones/goals |
71 |
-- yeah, again. once for flip, twice for displace |
72 |
the.clones:collide(the.player) |
|
24
by Josh C
intermidiate + win screens |
73 |
the.goalPerson:collide(the.player) -- will this fix? |
21
by Josh C
super hacky fix for passing through clones/goals |
74 |
|
10
by Josh C
collide w/ the map |
75 |
the.clones:collide(self.map) |
76 |
the.player:collide(self.map) |
|
16
by Josh C
moving goal, clones turning green... |
77 |
the.goalPerson:collide(self.map) |
10
by Josh C
collide w/ the map |
78 |
|
9
by Josh C
collision |
79 |
the.clones:collide() |
80 |
||
23
by Josh C
levels. ish. |
81 |
if math.random(1,6) == 1 then |
20
by Josh C
clones you flip don't flip back |
82 |
local c = the.clones.sprites[math.random(the.clones:count())] |
23
by Josh C
levels. ish. |
83 |
if self.level == 3 and not c.cured then |
20
by Josh C
clones you flip don't flip back |
84 |
c.image = 'data/goal.png' |
85 |
end |
|
16
by Josh C
moving goal, clones turning green... |
86 |
end |
87 |
||
3
by Josh C
add a couple other clones that move randomly |
88 |
the.player.moved = false |
89 |
end |
|
27
by Josh C
R = restart level |
90 |
|
91 |
if the.keys:justPressed('r') then |
|
92 |
the.app.view = GameView:new{level = self.level} |
|
93 |
end |
|
2
by Josh C
basic delayed movement |
94 |
end, |
95 |
} |
|
96 |
||
24
by Josh C
intermidiate + win screens |
97 |
SlowView = View:extend { |
98 |
onNew = function(self) |
|
28
by Josh C
vague warning about the blue things |
99 |
local texts = { |
100 |
'', |
|
101 |
"Your movements have slowed...", |
|
102 |
"Your movements have slowed...\nand they no longer only imitate you..." |
|
103 |
} |
|
104 |
||
24
by Josh C
intermidiate + win screens |
105 |
local text = Text:new { |
28
by Josh C
vague warning about the blue things |
106 |
text = texts[self.level], |
24
by Josh C
intermidiate + win screens |
107 |
--height = the.app.height, |
108 |
width = the.app.width, |
|
109 |
align = 'center', |
|
110 |
font = 18 |
|
111 |
} |
|
112 |
text:centerAround(the.app.width / 2, the.app.height / 2) |
|
113 |
self:add(text) |
|
114 |
||
115 |
self.timer:after(2, function() |
|
116 |
the.app.view = GameView:new{level = self.level} |
|
117 |
end) |
|
118 |
end |
|
119 |
} |
|
120 |
||
121 |
WinView = View:extend { |
|
122 |
onNew = function(self) |
|
123 |
local text = Text:new { |
|
124 |
text = 'You win!', |
|
125 |
width = the.app.width, |
|
126 |
align = 'center', |
|
127 |
font = 18 |
|
128 |
} |
|
129 |
text:centerAround(the.app.width / 2, the.app.height / 2) |
|
130 |
self:add(text) |
|
131 |
end |
|
132 |
} |
|
133 |
||
25
by Josh C
title screen |
134 |
TitleView = View:extend { |
135 |
onNew = function(self) |
|
136 |
self:add(Tile:new{ |
|
137 |
image = 'data/title.png' |
|
138 |
}) |
|
139 |
end, |
|
140 |
onUpdate = function(self) |
|
141 |
if the.keys:allJustPressed() then |
|
142 |
the.app.view = GameView:new{level = 1} |
|
143 |
end |
|
144 |
end |
|
145 |
} |
|
146 |
||
2
by Josh C
basic delayed movement |
147 |
the.app = App:new { |
29
by Josh C
name the game |
148 |
name = "One Among Many", |
15
by Josh C
put some walls and a goal... doesn't feel quite right. |
149 |
fps = 30, |
2
by Josh C
basic delayed movement |
150 |
onRun = function (self) |
151 |
print('Version: ' .. VERSION) |
|
152 |
||
25
by Josh C
title screen |
153 |
--self.view = GameView:new{level = 1} |
154 |
self.view = TitleView:new() |
|
2
by Josh C
basic delayed movement |
155 |
|
156 |
if DEBUG then |
|
157 |
self.console:watch('VERSION', 'VERSION') |
|
23
by Josh C
levels. ish. |
158 |
self.console:watch('level', 'the.view.level') |
2
by Josh C
basic delayed movement |
159 |
|
160 |
-- back off that dark overlay a bit |
|
161 |
self.console.fill.fill[4] = 75 |
|
162 |
end |
|
163 |
end, |
|
8
by Josh C
screenshots |
164 |
onUpdate = function (self, dt) |
165 |
if the.keys:justPressed('f1') then |
|
166 |
local ss = love.graphics.newScreenshot() |
|
167 |
ss:encode('screenshot-' ..love.timer.getTime()..'.png') |
|
168 |
end |
|
26
by Josh C
move quit keybindings to app |
169 |
|
170 |
if the.keys:justPressed('escape', 'q') then |
|
171 |
the.app:quit() |
|
172 |
end |
|
8
by Josh C
screenshots |
173 |
end |
2
by Josh C
basic delayed movement |
174 |
} |