-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLANDER1.BAS
83 lines (83 loc) · 2.36 KB
/
LANDER1.BAS
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
10 REM LEARNING BBC BASIC BY DOING
20 :
30 REM LUNAR LANDER BY EIGHTBITSWIDE
40 :
50 REM USES CONSOLE8 JOYSTICK
60 :
70 :
80 MB%=&40000
90 DIM graphics 1024
100 UP=253:DOWN=247:LEFT=223:RIGHT=127:FIRE=215
110 GRAVITY=10: DECENT=10
120 :
130 PROCloadSprite("lander0.rgb",0,16,16)
140 PROCloadSprite("lander1.rgb",1,16,16)
150 MODE 8
160 :
170 REM Set up some sprites
180 :
190 VDU 23,27,4,0 : REM Select sprite
200 VDU 23,27,5 : REM Clear frames for current sprite
210 VDU 23,27,6,0 : REM Add bitmap 0 as frame 0 of sprite
220 VDU 23,27,6,1 : REM Add bitmap 1 as frame 1 of sprite
230 VDU 23,27,11 : REM Show the sprite
240 :
250 VDU 23,27,7,1 : REM Activate sprite 1
260 :
270 GOTO 580
280 STOP
290 :
300 REM Load a bitmap into VDP RAM
310 REM F$ - Filename of bitmap
320 DEF PROCloadSprite(F$,N%,W%,H%)
330 OSCLI("LOAD " + F$ + " " + STR$(MB%+graphics))
340 VDU 23,27,0,N%
350 VDU 23,27,1,W%;H%;
360 FOR I%=0 TO (W%*H%*3)-1 STEP 3
370 r% = ?(graphics+I%+0)
380 g% = ?(graphics+I%+1)
390 b% = ?(graphics+I%+2)
400 a% = r% OR g% OR b%
410 VDU r%, g%, b%, a%
420 NEXT
430 ENDPROC
440 DEF PROC_MOVESPRITE(XX,YY)
450 VDU 23,27,13,XX;YY;
460 VDU 23,27,15 : REM UPDATE SPRITE
470 ENDPROC
480 DEF PROC_DELAY(DELAY)
490 TIME=0: REPEAT UNTIL TIME>DELAY
500 ENDPROC
510 DEF PROC_DRAWPLANET
520 VDU 23,200,0,0,0,0,0,0,173,82
530 PRINTTAB(0,26);
540 FOR DD=1 TO 40
550 PRINT CHR$(200);
560 NEXT DD
570 ENDPROC
580 :
590 REM **** GAME LOOP ****
600 :
610 PROC_DRAWPLANET
620 FUEL=15:Y=0
630 REPEAT
640 Y=Y+DECENT-9
650 TICK=TICK+1
660 IF TICK>5 THEN DECENT=DECENT+1:TICK=0
670 IF Y>198 THEN Y=198
680 PROC_MOVESPRITE(10,Y)
690 PROC_DELAY(DECENT)
700 PRINTTAB(0,0);"DECENT ";DECENT
710 IF FUEL>9 THEN PRINTTAB(0,1);"FUEL ";FUEL
720 IF FUEL<10 THEN PRINTTAB(0,1);"FUEL ";FUEL
730 JOY=GET(158)
740 IF (JOY AND UP)=JOY AND FUEL>0 THEN DECENT=DECENT-1:FUEL=FUEL-1
750 IF (JOY AND DOWN)=JOY THEN DECENT=DECENT+1
760 UNTIL Y>197
770 :
780 REM *** EVALUATE LANDING ***
790 :
800 PRINT
810 IF DECENT >11 THEN PRINT "YOU CRASHED!"
820 IF DECENT <12 THEN PRINT "HOUSTON, TRANQUITY BASE HERE."
830 IF DECENT <12 THEN PRINT "THE EAGLE HAS LANDED."