-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoodShepherd.bas
316 lines (282 loc) · 7.94 KB
/
GoodShepherd.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
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
1 RUN 9300
5 REM SET UP VARIABLES AND ARRAYS
8 LET H=0
11 BORDER 3
12 DIM W(250, 2): DIM S(250, 2)
13 LET W=1
14 LET S=0
17 LET F=0: LET G=2
18 LET E=0
30 LET L=1: LET T=1
35 REM LINES 36 - 45 JUST TURN CAPS LOCK ON
36 LET X=INT (PEEK 23658/8)
40 LET Y=2*INT (INT (PEEK 23658/8) /2)
45 IF X=Y THEN RANDOMIZE USR 4317
50 REM SET UP INITIAL SCREEN TO START GAME
60 CLS
61 LET A$=" "
62 REM TEN SPACES
63 INK 0
64 BRIGHT 0
65 PAPER 6
70 FOR n=0 TO 9
80 PRINT AT N,0;a$
90 NEXT n
92 PRINT AT 2,0;"Score:"
94 PRINT AT 4,0;"Feed:"
96 PRINT AT 6,0;"Level:"
97 PRINT AT 8,0;"Time:"
98 PAPER 7
99 PRINT AT 0,0; INK 0;"Hi-Score: "
100 PAPER 5
110 FOR N=10 TO 21
120 PRINT AT n,0;A$
130 NEXT n
135 PRINT AT 11,1;"THE FOLD"
140 INK 7: PAPER 7: BRIGHT 1
150 LET A$=A$+A$+" "
160 FOR N=0 TO 21
170 PRINT AT N,10; a$
180 NEXT N
185 PRINT AT 0,10; INK 0;H
190 PRINT AT 1,14; INK 0;"GOOD SHEPHERD"
320 FOR N=1 TO 3+(L*5)
324 LET A=2+RND*19
326 LET B=10+RND*21
330 PRINT AT A,B; INK 4;CHR$ 144
335 REM CHR$ 144= GRAPHICS A = GRASS
340 NEXT N
345 LET W(T,2)=10+RND*5+L
350 LET W(T,1)=12+RND*3-L
360 PRINT AT W(T,1),W(T,2); INK 1;CHR$ 145
370 REM CHR$ 145= GRAPHICS "B"= WOLF
380 LET S(T+L,1)=20
390 LET S(T+L,2)=9
400 FOR N=1 TO L
405 LET S(T+L-N,1)=20
410 LET S(T+L-N,2)=9-N
420 NEXT N
428 INK 3
430 PRINT AT S(T+L,1), S(T+L,2); CHR$ 146
431 REM CHR$ 146= GRAPHICS"C"= SHEPHERD
435 INK 2
440 FOR N=1 TO L
445 LET A=S(T+L-N,1)
446 LET B=S(T+L-N,2)
450 PRINT AT A,B; INK 0;CHR$ 147
455 REM CHR$ 147= GRAPHICS "D"= SHEEP
460 NEXT N
950 PRINT AT 6,7;L
960 FOR N=1 TO 90: NEXT N
970 PRINT AT 4,6;"LOW"
1000 REM MAIN LOOP TO RUN GAME
1005 PRINT AT 2,7;S
1006 PRINT AT 8,6; 151-T;
1007 IF 151-T<100 THEN PRINT " "
1010 LET T=T+1
1015 LET A$=INKEY$
1016 IF T<3+L AND A$="" THEN LET A$="W"
1020 LET A=S(T+L-1,1)+(A$="L")-(A$="P")
1025 LET B=S(T+L-1,2)+(A$="W")-(A$="Q")
1030 IF A=20 AND B<10 THEN GO TO 3100
1040 LET S(T+L,1)=A+(A<2)-(A>21)
1050 LET S(T+L,2)=B+(B<10)-(B>31)
1060 LET A=ATTR (S(T+L,1),S(T+L,2))
1065 IF A=124 THEN GO SUB 3000
1070 IF A=121 THEN GO SUB 5500
1080 IF A=120 THEN GO TO 5000
1090 IF A=40 THEN GO TO 6000
1092 IF S(T+L,1)=S(T+L-1,1) THEN GO TO 4500
1100 INK 3
1101 PRINT AT S(T+L,1),S(T+L,2);CHR$ 146
1104 LET A=S(T+L-1, 1)
1106 PRINT AT A,S(T+L-1,2); INK 0;CHR$ 147
1110 PRINT AT S(T-1,1),S(T-1,2); " "
1200 IF NOT W THEN GO TO 1500
1210 LET A=W(T-1,1)+(W(T-1,1)<S(T,1))
1215 LET A=A-(W(T-1,1)>S(T,1))
1220 LET B=W(T-1,2)+(W(T-1,2)<S(T,2))
1222 LET B=B-(W(T-1,2)>S(T,2))
1225 IF ATTR (A,B)=120 THEN GO TO 3200
1230 LET W(T,1)=A+(A<3)-(A>20)
1240 LET W(T,2)=B+(B<11)-(B>30)
1250 LET A=ATTR (W(T,1),W(T,2))
1260 IF A=120 THEN LET E=1
1270 IF A=123 THEN LET W(T,1)=W(T-1,1)
1275 IF A=123 THEN LET W(T,2)=W(T-1,2)
1280 PRINT AT W(T-1,1),W(T-1,2);" "
1290 PRINT AT W(T,1),W(T,2); INK 1;CHR$ 145
1300 IF E THEN GO TO 6500
1510 IF T=152 THEN GO TO 4000
2000 GO TO 1001
3000 REM EATEN GRASS
3005 BEEP .02,50: LET S=S+1: LET F=F+1
3010 IF G<F THEN PRINT AT 4,6;"0.K."
3020 RETURN
3100 LET S(T+L,1)=A: LET S(T+L,2)=B
3110 GO TO 1060
3201 LET W(T,1)=A: LET W(T,2)=B: GO TO 1250
4000 REM LOSE - OUT OF TIME
4005 PRINT AT 13,0;"TIME UP! "'"YOU SHOULD"
4010 PRINT "BE BACK BY"'"NOW. YOU "'"LOSE! "
4020 GO TO 6550
4500 LET A=S(T+L-1,2)
4501 IF S(T+L,2)<>A THEN GO TO 1093
4505 FOR N=L TO 1 STEP -1
4510 LET S(T+N-1,2)=S(T+N-2,2)
4520 LET S(T+N-1,1)=S(T+N-2,1)
4530 NEXT N
4540 GO TO 1200
5000 REM LOSE - SHEPHERD COLLIDES WITH A SHEEP
5010 PRINT AT S(T+L-1,1),S(T+L-1,2);" "
5015 FOR N=1 TO 14
5020 PRINT AT S(T+L,1),S(T+L,2);CHR$ 149
5035 BEEP RND*.01,10+RND*15
5045 NEXT N
5050 INK 0: PAPER 5
5060 PRINT AT 13,0;"YOU SHOULD"'"LEAD THE "
5065 PRINT "SHEEP: NOT"'"CRASH INTO"'"THEM! "
5070 GO TO 6550
5500 REM WOLF KILLED
5600 LET W=0
5610 FOR N=20 TO 45 STEP 1
5611 LET A=W(T-1,1)
5615 PRINT AT A,W(T-1,2); INK 2;CHR$ 145
5618 BEEP .004,N
5620 LET A=W(T-1,1)
5621 PRINT AT A,W(T-1,2); INK 3;CHR$ 147
5622 BORDER (N-20)/4
5623 LET A=W(T-1,1)
5624 PRINT AT A,W(T-1,2); INK 1;CHR$ 149
5625 NEXT N
5630 FOR N=1 TO 4+L
5632 LET S=S+1
5634 PRINT AT 2,7;S
5636 BEEP .1,20
5638 NEXT N
5665 BORDER 3
5690 RETURN
6000 REM WON-NEW LEVEL
6005 GO SUB 6200
6007 LET G=G+2
6010 FOR N=1 TO (150-T)/15
6012 LET S=S+1
6014 PRINT AT 2,7;S
6015 BEEP .1,30
6016 NEXT N
6020 LET L=L+1
6025 IF L=9 THEN LET L=8
6030 LET T=1
6050 LET F=0
6100 GO TO 60
6200 REM CHECK ENOUGH FOOD EATEN
6210 IF G>=F THEN GO TO 6400
6230 IF NOT W THEN LET W=1
6240 FOR N=1 TO 19
6250 BEEP .05,10+N
6260 NEXT N
6290 RETURN
6400 REM LOSE - NOT FED ENOUGH FOOD
6401 PRINT AT 13,0;"YOU DIDN'T"'"LET THEM "
6405 PRINT "EAT ENOUGH"'"FOOD! YOU "'"LOSE! "
6410 GO TO 6550
6500 REM LOSE - WOLF EATS SHEEP
6501 INK 0: PAPER 5
6505 FOR N=1 TO 10
6510 BEEP .5/N,-10-N
6515 NEXT N
6520 PRINT AT 13,0;"SORRY, YOU"'"LOST: BUT "
6540 PRINT "THE WOLF "'"ENJOYED "'"HIS LUNCH!"
6550 REM LIST - SET HISCORE AND OFFER NEW GAME
6551 FOR N=1 TO 9
6552 BEEP RND*.1,10+(RND*40)
6554 NEXT N
6555 PRINT '"PRESS Y TO"'"PLAY AGAIN"
6900 IF S>H THEN LET H=S
7000 LET A$=INKEY$
7010 IF A$<>"Y" THEN GO TO 7000
7020 GO TO 10
9000 REM USR GRAPHICS
9005 RESTORE
9010 FOR N=1 TO 6
9020 READ A$
9030 FOR M=0 TO 7
9040 READ A
9050 POKE USR A$+M,A
9060 NEXT M
9070 NEXT N
9080 RETURN
9100 DATA "A",0,0,0,0,8,42,46,127
9110 DATA "B",0,0,0,128,96,62,86,165
9120 DATA "C",39,117,36,36,252,36,84,84
9130 DATA "D",0,0,0,2,7,124,124,170
9140 DATA "E",64,73,46,28,124,166,42,200
9150 DATA "F",128,86,59,36,166,90,69,100
9200 REM CRIMMOND
9210 FOR N=1 TO 34
9220 READ A: READ B: BEEP A/5,B
9230 NEXT N
9240 DATA 2,0,4,9,1,10,1,7,4,12,1,10,1,7
9250 DATA 4,5,2,4,4,5,2,9,2,9,2,7,2,7,4,11,2
9260 DATA 11,10,12,2,9,2,9,2,10,2,9,4,7,2,9,2
9270 DATA 10,2,12,2,10,4,9,2,9,2,7,2,10,2,14
9280 DATA 4,5,2,4,8,5
9290 RETURN
9300 REM INITIAL INSTRUCTIONS
9310 INK 0: PAPER 6: BRIGHT 1: CLS
9320 PRINT AT 1,9;;"GOOD SHEPHERD."
9330 PRINT AT 3,3;"COPYRIGHT ";
9335 PRINT ;"S.SPRINGETT 1984"
9340 PRINT '"Your task is to lead the sheep"
9345 PRINT "to good pasture, and protect"
9350 PRINT "them from the wolf, who's hungry"
9355 PRINT "for a nice bit of mutton...."
9360 PRINT ''"You've only a limited time to "
9361 PRINT "ensure the sheep have had enough"
9362 PRINT "to eat, and avoid or kill the"
9363 PRINT "wolf. Of course you must not run"
9364 PRINT "into the flock itself, or the"
9365 PRINT "sheep will be scattered and lost"
9366 GO SUB 9000: REM USR GRAPHICS
9367 PRINT ';TAB 7;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 147;CHR$ 146
9368 GO SUB 9200: REM CRIMMOND
9370 PRINT '" Press any key to continue"
9371 IF INKEY$<>"" THEN GO TO 9371
9372 IF INKEY$="" THEN GO TO 9372
9373 CLS
9374 PRINT '''"When you have fed the sheep,"
9375 PRINT "take them back to the fold (you"
9376 PRINT "can get in only via the door you"
9377 PRINT "came out of) to get a new and"
9378 PRINT "larger flock to care for."
9379 PRINT '''"Kill the wolf by running himdown with the shepherd: butwatch out, because he's a trickycustomer!"
9387 PRINT ''" press any key to continue"
9388 IF INKEY$<>"" THEN GO TO 9388
9389 IF INKEY$="" THEN GO TO 9389
9390 CLS : PRINT 'TAB 12;"CONTROLS"
9393 PRINT '';TAB 5;"Keyboard controls are:"
9400 PRINT '';TAB 10;"Left: ""Q"""
9405 PRINT ;TAB 10;"Right: ""W"""
9410 PRINT ;TAB 10;"Up: ""P"""
9415 PRINT ;TAB 10;"Down: ""L"""
9420 PRINT ''TAB 7;"Good Shepherding!"
9430 PRINT ''; TAB 6;"Press ""S"" to start"
9440 IF INKEY$="s" THEN GO TO 9450
9441 IF INKEY$="S" THEN GO TO 9450
9445 GO TO 9440
9450 RUN 2
9950 REM WORKING SUBROUTINES
9970 PAPER 7: INK 0: BRIGHT 0: BORDER 7
9975 STOP
9980 SAVE "SHEPHERD" LINE 9300
9982 PRINT "REWIND AND PLAY TAPE TO VERIFY"
9986 VERIFY "SHEPHERD"
9987 PRINT '"PROGRAM VERIFIED"
9989 STOP
9990 INPUT "Program name to save "; LINE A$
9993 SAVE *"m";1;A$ LINE 9300
9994 VERIFY *"m";1;A$: PRINT A$;" VERIFIED"
9995 STOP
9997 INPUT "Program name to ERASE "; LINE A$
9998 ERASE "m";1;A$
9999 STOP