-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshmup.p8
406 lines (365 loc) Β· 17.1 KB
/
shmup.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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
pico-8 cartridge // http://www.pico-8.com
version 16
__lua__
function _init()
t=0
ship = {
sp=1,
x=60,
y=100,
h=4,
p=0,
t=0,
shipx=64,
shipy=64,
shipsize=3,
shipxdir=5,
shipydir=-3,
imm=false,
box = {x1=0,y1=0,x2=7,y2=7}}
bullets = {}
enemies = {
sp=17 or 18
}
explosions = {}
stars = {}
for i=1,128 do
add(stars,{
x=rnd(128),
y=rnd(128),
s=rnd(2)+1
})
end
start()
end
function respawn()
sfx(1)
local n = flr(rnd(9))+2
for i=1,n do
local d = -1
if rnd(1)<0.5 then d=1 end
add(enemies, {
sp=enemies.sp,
m_x=i*16,
m_y=60-i*8,
d=d,
x=-32,
y=-32,
r=12,
box = {x1=0,y1=0,x2=7,y2=7}
})
end
function shipcollide()
--left
if shipx<shipsize then
shipxdir=-shipxdir
end
--right
if shipx>128-shipsize then
shipxdir=-shipxdir
end
--top
if shipy<shipsize then
shipydir=-shipydir
end
end
end
function start()
_update = update_game
_draw = draw_game
end
function game_over()
_update = update_over
_draw = draw_over
sfx(2)
end
function update_over()
end
function draw_over()
cls()
print("game over",40,50,4)
end
function abs_box(s)
local box = {}
box.x1 = s.box.x1 + s.x
box.y1 = s.box.y1 + s.y
box.x2 = s.box.x2 + s.x
box.y2 = s.box.y2 + s.y
return box
end
function coll(a,b)
local box_a = abs_box(a)
local box_b = abs_box(b)
if box_a.x1 > box_b.x2 or
box_a.y1 > box_b.y2 or
box_b.x1 > box_a.x2 or
box_b.y1 > box_a.y2 then
return false
end
return true
end
function explode(x,y)
add(explosions,{x=x,y=y,t=0})
sfx(3)
end
function fire()
local b = {
sp=4,
x=ship.x,
y=ship.y,
dx=0,
dy=-3,
box = {x1=2,y1=0,x2=5,y2=4}
}
add(bullets,b)
end
function update_game()
t=t+1
if ship.imm then
ship.t += 1
if ship.t >30 then
ship.imm = false
ship.t = 0
end
end
for st in all(stars) do
st.y += st.s
if st.y >= 128 then
st.y = 0
st.x=rnd(128)
end
end
for ex in all(explosions) do
ex.t+=1
if ex.t==13 then
del(explosions,ex)
end
end
if #enemies <= 0 then
respawn()
end
for e in all(enemies) do
e.m_y += 1.3
e.x = e.r*sin(e.d*t/200) + e.m_x
e.y = e.r*cos(t/200) + e.m_y
if coll(ship,e) and not ship.imm then
ship.imm = true
ship.h -= 1
sfx(4)
if ship.h <= 0 then
game_over()
end
end
if e.y >= 150 then
del(enemies,e)
end
end
for b in all(bullets) do
b.x+=b.dx
b.y+=b.dy
if b.x < 0 or b.x > 128 or
b.y < 0 or b.y > 128 then
del(bullets,b)
end
for e in all(enemies) do
if coll(b,e) then
del(enemies,e)
ship.p += 1
explode(e.x,e.y)
end
end
end
if(t%6<3) then
ship.sp=2
else
ship.sp=3
end
if(t%6<3) then
enemies.sp=17
else
enemies.sp=18
end
if btn(β¬
οΈ) then ship.x-=2 end
if btn(β‘οΈ) then ship.x+=2 end
if btn(β¬οΈ) then ship.y-=2 end
if btn(β¬οΈ) then ship.y+=2 end
if btnp(π
ΎοΈ) then fire() sfx(0)
end
end
function draw_game()
cls()
for st in all(stars) do
pset(st.x,st.y,6)
end
print(ship.p,9)
if not ship.imm or t%8 < 4 then
spr(ship.sp,ship.x,ship.y)
end
for ex in all(explosions) do
circ(ex.x,ex.y,ex.t/3,8+ex.t%3)
end
for b in all(bullets) do
spr(b.sp,b.x,b.y)
end
for e in all(enemies) do
spr(e.sp,e.x,e.y)
end
for i=1,4 do
if i<=ship.h then
spr(33,80+6*i,3)
else
spr(34,80+6*i,3)
end
end
end
__gfx__
0000000000000000000dd000000dd000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000dd000005555000055550000a9a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700005555000555555005555550000900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0007700005555550d551155dd551155d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000d551155dd505505dd505505d000900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700d505505d000aa000000aa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000aa0000009000000009000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000900000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000200000020100001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000220000220120021000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000222112220110011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000222222221111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000023333201113311100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000022332201011110100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000002222000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000110000002200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000080800000606000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000888880006666600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000088800000666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000008000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__sfx__
0002000038350373502f3502d35028350203501b350183500e3500b35002350013500000005300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000300003f7503c7503a750367503475033750307502e7502d7502a750287502575022750217501e7501e7501b7501775016750157501375011750107500f7500d7500b7500a7500875005750047500375002750
00100000303502e3502e3502d3502e3502f35030350313503135031350303502c3502a35024350223501c35019350133500d35007350013500000000000000000000000000000000000000000000000000000000
000200003f6503c6503a6503765033650306502d650296502665021650206501a65016650136500d6500965005650016500000000000000000000000000000000000000000000000000000000000000000000000
000200001a75018750157501375012750107500e7500d7500c7500b7500b7500a75009750087500775005750057500475004750047500375003750027500275002750017500475002750017501d7001b7001a700
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__music__
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000
00 00000000