-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1hrgame268.p8
368 lines (332 loc) · 21.3 KB
/
1hrgame268.p8
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
pico-8 cartridge // http://www.pico-8.com
version 27
__lua__
best=0
home={
x=64,
y=64,
coins=0
}
player={
x=64,
y=64,
lives=3,
coins=0,
at_home=1
}
coins={}
enemies={}
function draw_coins()
for coin in all(coins) do
print("●", coin.x, coin.y, 10)
end
end
function draw_enemies()
for enemy in all(enemies) do
if(colliding(enemy,home,15)) then
print("😐", enemy.x, enemy.y, 6)
else
print("😐", enemy.x, enemy.y, 8)
end
end
end
function _update()
if (btn(0)) then player.x=player.x-1 end
if (btn(1)) then player.x=player.x+1 end
if (btn(2)) then player.y=player.y-1 end
if (btn(3)) then player.y=player.y+1 end
detect_collisions()
update_enemies()
end
function update_enemies()
if(player.at_home == 1) then
return
end
for enemy in all(enemies) do
if(enemy.d == 1) then
enemy.x=enemy.x+enemy.speed
elseif (enemy.d == 2) then
enemy.x=enemy.x-enemy.speed
elseif (enemy.d == 3) then
enemy.y=enemy.y+enemy.speed
else
enemy.y=enemy.y-enemy.speed
end
if(enemy.x<=0) then
enemy.d=1
end
if(enemy.x>=120) then
enemy.d=2
end
if(enemy.y<=0) then
enemy.d=3
end
if(enemy.y>=120) then
enemy.d=4
end
end
end
function colliding(a, b, e)
xhit=abs(a.x-b.x) <= e
yhit=abs(a.y-b.y) <= e
return (xhit and yhit)
end
function _draw()
cls()
print("⌂", home.x, home.x, 11)
rect(58, 58, 76, 76, 3)
draw_coins()
draw_enemies()
spr(1, player.x, player.y)
print(player.coins.." coin(s), "..home.coins.." safe, "..player.lives.." lives", 0, 0, 7)
print("best: "..best, 0, 120, 7)
end
-->8
function detect_collisions()
pickup_coins()
enemy_collide()
enter_home()
end
function pickup_coins()
for coin in all(coins) do
if(colliding(coin, player, 5)) then
sfx(0)
del(coins, coin)
player.coins=player.coins+1
end
end
end
function enemy_collide()
for enemy in all(enemies) do
_with_player=colliding(enemy, player, 5)
_with_home=colliding(enemy,home,15)
if(_with_home and _with_player) then
sfx(3)
return
end
if(_with_player) then
sfx(2)
player.coins=0
player.at_home=1
player.x=home.x
player.y=home.y
player.lives=player.lives-1
if(player.lives == 0) then
reset()
end
end
end
end
function reset()
sfx(4)
player={
x=64,
y=64,
lives=3,
coins=0,
at_home=1
}
home.coins=0
generate_coins()
generate_enemies()
end
function enter_home()
if(colliding(player,home,10)) then
if(player.at_home == 0) then
sfx(1)
generate_coins()
randomize_enemies()
end
player.at_home=1
if(player.coins > 0) then
home.coins=home.coins+player.coins
player.coins=0
if (home.coins > best) then
best = home.coins
end
end
else
player.at_home=0
end
end
-->8
function generate_coins()
coins={}
for i=0,10 do
repeat
_coin={
x=ceil(rnd(120)),
y=ceil(rnd(120))
}
until (not colliding(_coin, home, 20))
add(coins, _coin)
end
end
function generate_enemies()
enemies={}
for i=0,15 do
repeat
_enemy={
x=ceil(rnd(120)),
y=ceil(rnd(120)),
d=flr(rnd(4))+1,
speed=rnd(1.5)+0.75
}
until (not colliding(_enemy,home,15))
add(enemies, _enemy)
end
end
function randomize_enemies()
for enemy in all(enemies) do
enemy.d=flr(rnd(4))+1
enemy.speed=rnd(1.5)+0.75
end
end
generate_coins()
generate_enemies()
__gfx__
0000000000bbb00000aaa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000bbbbb000aaaaa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700007f7000aaaaaaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0007700000fff000aaaaaaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000770000f111f00aaaaaaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700001110000aaaaa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000011100000aaa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000a0a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__label__
77700000077007707770770007000770070000000000777000000770777077707770000000007770000070007770707077700770000000000000000000000000
70700000700070700700707070007000007000000000707000007000707070007000000000000070000070000700707070007000000000000000000000000000
70700000700070700700707070007770007000000000707000007770777077007700000000000770000070000700707077007770000000000000000000000000
70700000700070700700707070000070007007000000707000000070707070007000070000000070000070000700777070000070000000000000000000000000
77700000077077007770707007007700070070000000777000007700707070007770700000007770000077707770070077707700000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000088888880000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000080888080000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000088888880000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000080000080000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000088888880000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000088888880000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000088888880000000000000000000080888080000000000000000000000000000000000000000000000000000000000000000000
00000000000888888800000000080888080000000000000000000088888880000000000000000000000000000000000000000000000000000000000000000000
00000000000808880800000000088888880000000000000000000080000080000000000000000000000000000000000000000000000000000000000000000000
00000000000888888800000000080000080000000000000000000088888880000000000000000000000000000000000000000000000000000000000000000000
00000000000800000800000000088888880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000888888800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaa00000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaa0a0000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaa0000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaa0000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaa00000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000888888800000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000808880800000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000008888888000000000000aaa00000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000800000800000000000aaa0a0000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000888888800000000000aaaaa0000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000aaaaa0000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000aaa00000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008888888000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008088808000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008888888000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000008000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008888888000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaa00000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaa0a0000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaa0000000
00000088888880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaa0000000
000000808880800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaa00000000
00000088888880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000080000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000088888880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008888888aa00000000000000000000000000000
00000000000000000000000000000000000000000000000000000000003333333333333333333000000000000080888a8a0a0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000300000000000000000300000000000008888888aaa0000000000000000000000000000
00000000000000000000000000000000000000000000000000000000003000000000000000003000000000000080000a8aaa0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000300000000000000000300000000000008888888aaa0000000000000000000000000000
00000000000000000000000000000000000000000000000000000000003000000000000000003000000000000000000aaaaa0000000000000000000000000000
00000000000000000000000000000088888880000000000000000000003000000000000000003000000000000000000aaaaa0000000000000000000000000000
000000000000000000000000000000808880800000000000000000000030000000bbb000000030000000000000000000aaa00000000000000000000000000000
00000000000000000000000000000088888880000000000000000000003000000bbbbb0000003000000000000000000000000000000008888888000000000000
0000000000000000000000000000008000008000000000000000000000300000bb7f7bb000003000000000000000000000000000000008088808000000000000
00000000000000000000000000000088888880000000000000000000003000000bfffb0000003000000000000000000000000000000008888888888888000000
00000000000000000000000000000000000000000000000000000000003000000f111f0000003000000000000000000000000000000008000008088808000000
00000000000000000000000000000000000000000000000000000000003000000011100000003000000000000000000000000000000008888888888888000000
00000000000000000000000000000000000000000000888888800000003000000011100000003000000000000000000000000000000000000008000008000000
000000000000000000000000000000000000000000008088808000000030000000a0a00000003000000000000000000000000000000000000008888888000000
00000000000000000000000000000000000000000000888888800000003000000000000000003000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000800000800000003000000000000000003000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000888888800000003000000000000000003000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000003000000000000000003000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000003333333333333333333000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000088888880000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080888080000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000088888880000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000080000000000000000000000000
00000000000000000888888800000000000000000000000000000000000000000000000000000000000000000000000088888880000000000000000000000000
0000000000000000080888080000000000000000000000000000000000000000000000000000000000aaaaa00000000000000000000000000000000000000000
000000000000000008888888000000000000000000000000000000000000000000000000000000000aaaaa0a0000000000000000000000000000000000000000
000000000000000008000008000000000000000000000000000000000000000000000000000000000aaaaaaa0000000000000000000000000000000000000000
000000000000000008888888000000000000000000000000000000000000000000000000000000000aaaaaaa0000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000aaaaa00000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000008888888000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000008088808000000000000000000088888880000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000008888888000000000000000000080888080000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000008000008000000000000000000088888880000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000008888888000000000000000000080000080000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000088888880000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000aaa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000aaa0a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000aaaaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000aaaaa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000aaa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000aaa000000000000000000000000000000000000000000
00000000000000000000000000000aaa00000000000000000000000000000000000000000000000000aaa0a0000000000000000000000000000aaa0000000000
7770777007707770000000007770aaa0a0000000000000000000000000000000000000000000000000aaaaa000000000000000000000000000aaa0a000000000
7070700070000700070000007070aaaaa0000000000000000000000000000000000000000000000000aaaaa000000000000000000000000000aaaaa000000000
7700770077700700000000007070aaaaa00000000000000000000000000000000000000000000000000aaa0000000000000000000000000000aaaaa000000000
70707000007007000700000070700aaa00000000000000000000000000000000000000000000000000000000000000000000000000000000000aaa0000000000
77707770770007000000000077700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__sfx__
000100001015011150101501015010150101501014011140121401314016140181501d15024150371503715000100001000010000100001000010000100001000010000100001000010000100001000010000100
00010000110500f0500e0500d0500c0500b0500b0500a0500a0500a05009050090500a0500a0500a0500b0500c0500d0500e0501005011050130501505017050180501a0501b0501d0502005023050270502d050
000100001c3502035022350273502b3502d35030350313502a350233501e3501c3501c3501d3501e350203502335024350233501f3501b3501b3501c3501e3502035021350213501e3501b350163501335012350
000200000101001010010000100004000050000400001600016000160001600016000160002600026000260003600036000360003600036000860008600086000860008600086000860009600000000000000000
0002000036470334602c4602646024450244502645027450294502a4502a440264401e4401844015440184401a4301b4301d4301e4301d430154300f4300c4200c4200e4201042011420114200a4200342002410
__music__
00 01424344