-
Notifications
You must be signed in to change notification settings - Fork 9
/
BBCMicro.txt
99 lines (88 loc) · 3.47 KB
/
BBCMicro.txt
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 REM === BASIC Month 3: Cannonball
110 REM === http://reddit.com/RetroBattlestations
120 REM === written by Fozztexx
130 REM === BBC Micro version by mattinx
200 REM === Clear screen and setup variables
210 CLS
220 CL = 40:RW = 32:REM Columns and Rows of the screen
230 CA = 45:CN = 5:REM Angle and length of the cannon
240 CX = 5:PX = CL-5:SC = 0:LV = 3
250 LA = 0:PX% = 0:BX% = 0:BY% = 0
260 REM Set cursor keys to return values
270 *FX 4,1
280 MODE 1:REM Set to 40 col mode
300 REM === Play game
310 CV = INT(RND(1) * 15) + 10:GOSUB 4010:GOSUB 2010
320 GOSUB 2510
330 IF KE$ = "A" OR KE$ = "a" OR KE$ = CHR$(136) THEN CA = CA + 5:IF CA > 85 THEN CA = 85
340 IF KE$ = "Z" OR KE$ = "z" OR KE$ = CHR$(137) CA = CA - 5:IF CA < 15 THEN CA = 15
350 IF KE$ = "Q" OR KE$ = "q" THEN END
360 IF KE$ = " " THEN GOTO 410
370 GOSUB 1010
380 GOTO 320
400 REM === Fire!
410 LX = (CN + 1) * COS((360 - CA) * PI / 180):LY = (CN + 1) * SIN((360 - CA) * PI / 180)
420 BX = CX + LX:BY = RW + LY
430 GOSUB 1510
440 VX = CV * COS((360 - CA) * PI / 180):VY = CV * SIN((360 - CA) * PI / 180)
500 REM === Move player and animate ball
510 GOSUB 2510
520 IF KE$ = CHR$(136) THEN PX = PX - 1:IF PX < CX + CN THEN PX = CX + CN
530 IF KE$ = CHR$(137) THEN PX = PX + 1:IF PX > CL - 1 THEN PX = CL - 1
540 GOSUB 2010
550 BX = BX + (VX / 10):BY = BY + (VY / 10):GOSUB 1510
560 VY = VY + 2
570 IF BY < RW THEN GOTO 510
580 P$ = " ":X1%=BX%:Y1%=BY%:GOSUB 3510
600 REM === Score or die
610 LX = BX - BX%:LY = BY - BY%:L2 = RW - BY%
620 IX = BX% + LX * (L2 / LY)
630 IF IX >= PX - 1 AND IX <= PX + 1 THEN SC = SC + 10:GOTO 310
640 LV = LV - 1:GOSUB 4010
650 IF LV < 1 THEN P$="GAME OVER":X1% = (CL - LEN(P$)) / 2:Y1% = RW / 2:GOSUB 3510:END
660 GOTO 310
1000 REM === Draw cannon
1010 IF (CA = LA) THEN RETURN
1020 P$="ANGLE: "+STR$(CA)+" ":X1%=2:Y1%=1:GOSUB 3510
1030 LX = CN * COS((360 - LA) * PI / 180):LY = CN * SIN((360 - LA) * PI / 180)
1040 X1 = CX:Y1 = RW:X2 = X1 + LX:Y2 = Y1 + LY:P$ = " ":GOSUB 3010
1050 LX = CN * COS((360 - CA) * PI / 180):LY = CN * SIN((360 - CA) * PI / 180)
1060 X2 = X1 + LX:Y2 = Y1 + LY:P$ = "%":GOSUB 3010
1070 LA = CA:RETURN
1500 REM === Draw ball
1510 X1% = BX:Y1% = BY:P$="o":GOSUB 3510
1520 IF BX% <> X1% OR BY% <> Y1% THEN X1%=BX%:Y1%=BY%:P$=" ":GOSUB 3510
1530 BX% = BX:BY% = BY
1540 RETURN
2000 REM === Draw player
2010 P$="U":X1% = PX:Y1% = RW:GOSUB 3510
2020 IF PX% <> X1% THEN X1%=PX%:P$=" ":GOSUB 3510
2030 PX% = PX
2040 RETURN
2500 REM === Read the keyboard
2510 KE$ = INKEY$(0)
2520 RETURN
3000 REM === Plot a line
3010 X1% = X1:X2% = X2:Y1% = Y1:Y2% = Y2
3020 DX% = ABS(X2% - X1%):SX% = -1:IF X1% < X2% THEN SX% = 1
3030 DY% = ABS(Y2% - Y1%):SY% = -1:IF Y1% < Y2% THEN SY% = 1
3040 ER% = -DY%:IF DX% > DY% THEN ER% = DX%
3050 ER% = ER% / 2
3060 GOSUB 3510
3070 IF X1% = X2% AND Y1% = Y2% THEN RETURN
3080 E2% = ER%
3090 IF E2% > -DX% THEN ER% = ER% - DY%:X1% = X1% + SX%
3100 IF X1% = X2% AND Y1% = Y2% THEN RETURN
3110 IF E2% < DY% THEN ER% = ER% + DX%:Y1% = Y1% + SY%
3120 IF X1% = X2% AND Y1% = Y2% THEN RETURN
3130 GOTO 3060
3500 REM === Plot a point
3510 IF X1% < 1 OR X1% > CL OR Y1% < 1 OR Y1% > RW THEN RETURN
3520 PRINT TAB(X1%-1, Y1%-1);
3530 PRINT P$;
3540 RETURN
4000 REM === Show score/lives/velocity
4010 P$="VELOCITY: "+STR$(CV)+" ":X1% = CL / 3:Y1%=1:GOSUB 3510
4020 P$="SCORE: "+STR$(SC):X1% = CL * 2 / 3:GOSUB 3510
4030 P$=MID$(" UUU",LV+1,3):X1%=CL - 2:GOSUB 3510
4040 RETURN