-
Notifications
You must be signed in to change notification settings - Fork 0
/
hockey.bas
119 lines (119 loc) · 3.58 KB
/
hockey.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
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
10 ' Space-Hockey
20 ' David Hay
30 ' Amstrad Action March 1989
40 MODE 1:CLS
50 PRINT" S P A C E - H O C K E Y"
60 LOCATE 1,15
70 PRINT" <FIRE> TO START"
80 IF INKEY(76)>-1 OR INKEY(9)>-1 THEN 100 ELSE 60
90 ' SET UP SCREEN
100 INK 0,0:PEN 1:PAPER 0
110 t%=1000:BORDER 11:CLS
120 ' CHARACTERS
130 SYMBOL AFTER 92
140 SYMBOL 93,24,60,102,195,192,0,0,0
150 SYMBOL 251,0,24,60,36,102,102,255,219
160 SYMBOL 252,219,255,102,102,36,60,24,0
170 SYMBOL 253,3,15,62,99,99,62,15,3
180 SYMBOL 254,192,240,124,198,198,124,240,192
190 SYMBOL 255,24,44,94,126,60,24
200 ' GAME SCREEN
210 x%=5:y%=16:a%=35:b%=5:g%=20:h%=11
220 LOCATE 1,23
230 PRINT"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]"
240 LOCATE 1,24
250 PRINT" S P A C E - H O C K E Y "
260 LOCATE 1,25
270 PRINT" 1: 2:"
280 LOCATE 6,25:PRINT xs%
290 LOCATE 36,25:PRINT as%
300 LOCATE 1,5:PRINT"="
310 LOCATE 40,5:PRINT"="
320 LOCATE 1,17:PRINT"="
330 LOCATE 40,17:PRINT"="
340 s%=253:p%=254
350 LOCATE x%,y%:PRINT CHR$(254)
360 LOCATE a%,b%:PRINT CHR$(253)
370 PEN 2:LOCATE g%,h%
380 PRINT CHR$(255):PEN 1
390 ' MAIN PROG
400 ox%=x%:oy%=y%:oa%=a%:ob%=b%
410 og%=g%:oh%=h%:t%=t%-1
420 LOCATE 18,25:PRINT t%
430 IF t%=0 THEN 1090
440 ' CONTROL
450 IF INKEY(9)>-1 THEN a%=39
460 IF INKEY(0)>-1 THEN b%=b%-1:s%=251
470 IF INKEY(2)>-1 THEN b%=b%+1:s%=252
480 IF INKEY(8)>-1 THEN a%=a%-1:s%=253
490 IF INKEY(1)>-1 THEN a%=a%+1:s%=254
500 IF INKEY(76)>-1 THEN x%=39
510 IF INKEY(72)>-1 THEN y%=y%-1:p%=251
520 IF INKEY(73)>-1 THEN y%=y%+1:p%=252
530 IF INKEY(74)>-1 THEN x%=x%-1:p%=253
540 IF INKEY(75)>-1 THEN x%=x%+1:p%=254
550 IF x%>39 THEN x%=39
560 IF x%<2 THEN x%=2
570 IF a%<2 THEN a%=2
580 IF a%>39 THEN a%=39
590 IF b%<1 THEN b%=1
600 IF b%>22 THEN b%=22
610 IF y%<1 THEN y%=1
620 IF y%>22 THEN y%=22
630 ' PRINT CHARACTERS
640 LOCATE ox%,oy%:PRINT" "
650 LOCATE oa%,ob%:PRINT" "
660 PEN 11:LOCATE x%,y%:PRINT CHR$(p%)
670 PEN 1:LOCATE a%,b%:PRINT CHR$(s%)
680 ' COLLISION DETECTION
690 IF x%=g%-1 AND y%=h% OR a%=g%-1 AND b%=h% THEN 780
700 IF x%=g%+1 AND y%=h% OR a%=g%+1 AND b%=h% THEN 790
710 IF x%=g% AND y%=h% OR a%=g%+2 AND b%=h%-1 THEN 800
720 IF x%=g% AND y%=h%+1 OR a%=g% AND b%=h%+1 THEN 810
730 IF x%=g%-1 AND y%=h%-1 OR a%=g%-1 AND b%=h%-1 THEN 820
740 IF x%=g%+1 AND y%=h%-1 OR a%=g%+1 AND b%=h%-1 THEN 830
750 IF x%=g%+1 AND y%=h%+1 OR a%=g%+1 AND b%=h%+1 THEN 840
760 IF x%=g%-1 AND y%=h%+1 OR a%=g%-1 AND b%=h%+1 THEN 850
770 GOTO 400
780 g%=g%+5:GOTO 860
790 g%=g%-5:GOTO 860
800 h%=h%+5:GOTO 860
810 h%=h%-1:GOTO 860
820 g%=g%+5:h%=h%+5:GOTO 860
830 g%=g%-5:h%=h%+5:GOTO 860
840 g%=g%-5:h%=h%-5:GOTO 860
850 g%=g%+5:h%=h%-5
860 SOUND 1,30,10,7
870 IF g%<2 AND h%<17 AND h%>5 THEN 970
880 IF g%>39 AND h%<17 AND h%>5 THEN 1010
890 IF g%>38 THEN g%=38
900 IF g%<3 THEN g%=3
910 IF h%>21 THEN h%=21
920 IF h%<2 THEN h%=2
930 PEN 2:LOCATE og%,oh%:PRINT" "
940 LOCATE g%,h%:PRINT CHR$(255)
950 PEN 1:GOTO 400
960 ' GOAL SCORED
970 g%=1:LOCATE og%,oh%:PRINT" "
980 LOCATE g%,h%:PRINT CHR$(255)
990 as%=as%+1:g%=1
1000 GOTO 1040
1010 g%=40:LOCATE og%,oh%:PRINT" "
1020 LOCATE g%,h%:PRINT CHR$(255)
1030 xs%=xs%+1:g%=40
1040 FOR fx%=5 TO 15 STEP -1
1050 SOUND 2,0,15,5,0,0,fx%
1060 NEXT
1070 p%=254:s%=253:CLS:GOTO 210
1080 ' END GAME
1090 FOR fy%=5 TO 15:SOUND 1,fy%,10,7
1100 NEXT fy%
1110 CLS
1120 PRINT" G A M E O V E R"
1130 LOCATE 1,5
1140 PEN 11:PRINT"PLAYER 1";xs%
1150 LOCATE 1,10
1160 PEN 1:PRINT"PLAYER 2";as%
1170 LOCATE 1,20
1180 PRINT" <FIRE> TO PLAY AGAIN"
1190 IF INKEY(76)>-1 OR INKEY(9)>-1 THEN 40 ELSE 1190