-
Notifications
You must be signed in to change notification settings - Fork 0
/
pac2600.prg
547 lines (394 loc) · 8.71 KB
/
pac2600.prg
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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
/***
PAC-MAC 2600
Remake using DIV Games studio
Started: 29/03/2015 20:26
***/
program pac2600;
global sounds[10];
player=0;
start=0;
playing=false;
score=0;
gactive=0;
powertime=0;
powersound=0;
numghosts=4;
flicker=1;
demo=1;
lives=0;
local
p=0;
ox=0;
oy=0;
nx=0;
ny=0;
dx=0;
dy=0;
ody=0;
odx=0;
anim=0;
animf=0;
eyes=false;
BEGIN
load_fpg("pac2600.fpg");
sounds[0]=load_wav("sounds/CHOMP.wav",0);
sounds[1]=load_wav("sounds/BOOP.wav",0);
sounds[2]=load_wav("sounds/START.wav",0);
sounds[3]=load_wav("sounds/DEATH.wav",0);
sounds[4]=load_wav("sounds/beeew.wav",1);
sounds[5]=load_wav("sounds/BUP_BWOOP.wav",0);
sounds[6]=load_wav("sounds/WHISTLE.wav",0);
put_screen(file,100);
set_fps(60,0);
write_int(0,160,180,5,&score);
write_int(0,0,180,3,&lives);
LOOP
playing=false;
maze();
frame;
WHILE(get_id(type wafer) || get_id(type powerpill))
FRAME;
gactive ;
IF(gactive==4)
gactive=0;
END
IF(powertime>0)
powertime--;
IF(powertime==0)
stop_sound(powersound);
END
END
if(key(_enter) && demo==true)
load_pal("pac2600.fpg");
demo=false;
playing=false;
score=0;
lives=3;
signal(type maze, s_kill_tree);
maze();
end
END
signal(type maze, s_kill_tree);
if(powertime>0)
stop_sound(powersound);
powertime=0;
end
END
END
PROCESS maze()
PRIVATE
px;
py;
BEGIN
/*
signal(type ghost, s_kill);
signal(type wafer, s_kill);
signal(type powerpill, s_kill);
signal(type pac, s_kill);
signal(type bonus, s_kill);
*/
// setup wafers
FROM x = 9 to 134;
get_point(file,101,x,&px, &py);
wafer(px,py);
END
// setup powerpills
FROM x = 1 to 4;
get_point(file,101,x,&px,&py);
powerpill(px,py);
end
LOOP
// position pacman
if(!demo)
get_point(file,101,5,&px, &py);
player=pac(px,py);
else
player=id;
end
// position ghosts
get_point(file,101,7,&px, &py);
for( x = 1 ;x<=numghosts;x );
ghost(px,py,x-1);
END
if(demo)
frame(6000);
playing=true;
end
frame;
WHILE(get_id(type pac) || demo)
if(demo)
roll_palette(1,254,rand(0,255));
frame(10000);
else
FRAME;
end
END
signal(type ghost, s_kill);
signal(type pac, s_kill);
debug;
lives--;
if(lives<0)
demo=1;
end
END
END
PROCESS pac(x,y)
PRIVATE
frames[]=1,2,3,2;
eatsound=0;
g=0;
BEGIN
y ;
x--;
graph=frames[0];
FRAME(6000);
start = sound(sounds[2],255,255);
LOOP
IF(playing==true || !is_playing_sound(start))
playing=true;
ox=x;
oy=y;
IF(key(_left))
x-=2;
nx=-2;
ny=0;
END
IF(key(_right))
x =2;
nx=2;
ny=0;
END
IF(key(_up))
y-=2;
ny=-2;
nx=0;
END
IF(key(_down))
y =2;
ny=2;
nx=0;
END
p=map_get_pixel(file,101,x,y-1);
IF((x!=ox || y!=oy) && p!=0 & p!=39)
dx=nx;
dy=ny;
ELSE
x=ox;
y=oy;
x=x dx;
y=y dy;
p=map_get_pixel(file,101,x,y-1);
IF(p==0 || p==39)
x=ox;
y=oy;
dx=0;
dy=0;
END
END
END
IF(anim >10)
anim=0;
animf ;
IF(animf==4)
animf=0;
END
graph=frames[animf];
END
g=collision(type ghost);
IF(g)
if(g.eyes==false)
IF(powertime<1)
playing=false;
sound(sounds[3],255,255);
FROM graph = 4 to 10;
FRAME(1600);
END
RETURN;
ELSE
g.eyes=true;
playing=false;
eatsound=sound(sounds[5],255,255);
WHILE(is_playing_sound(eatsound))
IF(anim >10)
anim=0;
animf ;
IF(animf==4)
animf=0;
END
graph=frames[animf];
END
FRAME;
END
sound(sounds[6],255,255);
playing=true;
END
END
END
FRAME;
END
END
PROCESS ghost(x,y,gid);
private
homex=0;
homey=0;
ograph=0;
try1=0;
sw=0;
BEGIN
homex=x;
homey=y;
dx=1;
graph=30;
LOOP
IF(playing)
p = map_get_pixel(file,101,x,y-1);
IF(p==54)
ox=dx;
oy=dy;
dx=0;
dy=0;
END
if(eyes)
try1=4;
else
try1=0;
end
WHILE(dx==0 && dy==0)
IF(eyes && try1>0)
switch(try1)
case 1:
IF(homex>x)
dx=1;
END
end
case 2:
if(homex<x && dx==0)
dx=-1;
END
end
case 3:
if(homey<y && dx==0)
dy=-1;
END
end
case 4:
if(homey>y && dx==0 && dy==0)
dy=1;
END
end
end
ELSE
sw=rand(0,3);
SWITCH(sw)
CASE 0:
if(homex>x && try1>0)
dx=1;
else
dx=1;
end
END
CASE 1:
if(homex<x && try1>0)
dx=-1;
else
dx=-1;
end
END
CASE 2:
if(homey>y && try1>0 )
dy=1;
else
dy=1;
end
END
CASE 3:
if(homey<y && try1>0)
dy=-1;
else
dy=-1;
end
END
END
END
if(dx!=0 || dy!=0)
p=map_get_pixel(file,101,x dx,y-1 dy);
IF(p==0 || (!eyes && p==39 && dx==-1) )
dx=0;
dy=0;
END
IF(dx==-ox && dy==-oy)
dx=0;
dy=0;
END
end
try1--;
END
ox=x;
oy=y;
if(eyes==1 && homex==x && homey==y)
if(powertime<1)
eyes=false;
dx=0;
dy=0;
end
else
x=x dx;
y=y dy;
end
END
IF(y<-20)
y =200;
END
IF(y>200)
y-=200;
END
IF(anim >10)
anim=0;
graph ;
IF(graph==34)
graph=30;
END
END
ograph=graph;
IF(eyes==true)
graph=34;
END
if(flicker)
size=100*(gid%4==gactive);
end
IF(powertime>0)
graph =10;
END
FRAME;
graph=ograph;
END
END
PROCESS wafer(x,y)
BEGIN
graph=20;
REPEAT
FRAME;
UNTIL (player.y-1==y && abs(player.x-(x 4))<5)
sound(sounds[0],255,255);
score ;
END
PROCESS powerpill(x,y)
BEGIN
graph=21;
REPEAT
size=100*((timer/20)&1);
FRAME;
UNTIL(abs(x-player.x)<2 && abs(y-player.y)<2)
stop_sound(powersound);
sound(sounds[1],255,255);
score =10;
powersound=sound(sounds[4],255,255);
powertime=600;
END
PROCESS bonus(x,y)
BEGIN
graph=22;
LOOP
FRAME;
END
END