Browse Source

add ROCKWARS.BAS and a stub README

Brennen Bearnes 5 years ago
commit
93c6ccb148
2 changed files with 603 additions and 0 deletions
  1. 7
    0
      README
  2. 596
    0
      ROCKWARS.BAS

+ 7
- 0
README View File

@@ -0,0 +1,7 @@
1
+QBasic Rockwars
2
+
3
+A take on the classic artillery game. It features two little castles, an
4
+inexorably advancing tank (with a laser!) and a tiny orbiting moon.
5
+
6
+You'd need a working qbasic.exe to run this, although FreeBASIC might do the
7
+trick with a little work.

+ 596
- 0
ROCKWARS.BAS View File

@@ -0,0 +1,596 @@
1
+'QBasic Rockwars v1.1, by Brennen Bearnes
2
+'Version 1.1 has the following changes:
3
+'1. A startup menu with the ability to change game settings.
4
+'2. 3 different types of game.
5
+'3. End screen now asks if you want to play again.
6
+'4. A few small changes and optimizations (I hope).
7
+
8
+'You play the part of the blue castle.  You've been attacked by
9
+'the red castle, who has started sending robotic tanks equipped with
10
+'a short range death ray at you.  Fortunately, you've been hard at work
11
+'on your own secret weapon, a powerful catapult that can launch rocks
12
+'all the way to the other side of the screen.
13
+
14
+'How to play:
15
+'A tank will start coming at you as soon as the game begins.  If the
16
+'red castle is fairly close, then you should shoot the tank first.
17
+'Every time you blow up a tank, the red castle sends another one,
18
+'so sooner or later, you'll have to hit the castle.  To fire, press
19
+'F1, and type in the angle (10-180) and velocity (0-100) you want.  Be
20
+'sure to take the wind into account.  If the tank gets close enough,
21
+'then you're toast.
22
+
23
+'Brent P. Newhall did all the code for the explosions, as well as the star
24
+'field, and a number of other small but effective changes.
25
+'The little moon orbiting a planet in the background was done
26
+'by Marco Koegler (and thanks to everyone else that told me how to do it).
27
+'I figured out how to plot the projectiles from GORILLA.BAS, which I
28
+'found on an old computer at school.
29
+
30
+'Suggestions are welcome, and if you improve this in any way, please
31
+'send me a copy.
32
+'bbearnes@worldnet.att.net
33
+'http://www.geocities.com/SiliconValley/Park/8994/
34
+
35
+' Brent P. Newhall edited 9/30/96
36
+' Notes: The explode code now restores the screen to how it looked prior
37
+'        to the explosion.  I then added code to erase the bullet and
38
+'        exploded item just after the explosion.  I also added the stars.
39
+'        Before, you could enter an angle of zero and just wipe out
40
+'        anything before you.  Now the angle can be no less than 10.
41
+'        I've also cleaned up the code a bit, making it more readable,
42
+'        less time- and memory-intensive, etc.
43
+
44
+'Thanks Brent!
45
+
46
+DECLARE SUB newTank ()
47
+DECLARE SUB drawTank ()
48
+DECLARE SUB newRock ()
49
+DECLARE SUB drawRock ()
50
+DECLARE SUB explode (green%, blue%, red%, boomX, boomY, boomSize)
51
+
52
+CONST pi=3.141592654#
53
+
54
+TYPE arctype
55
+Radius AS INTEGER
56
+colr AS INTEGER
57
+p1 AS SINGLE
58
+p2 AS SINGLE
59
+END TYPE
60
+
61
+Restart:
62
+
63
+'Variables that control the rock
64
+DIM SHARED rockAngle
65
+DIM SHARED rockSpeed
66
+DIM SHARED startRockX
67
+DIM SHARED startRockY
68
+DIM SHARED oldRockX
69
+DIM SHARED oldRockY
70
+DIM SHARED Rock1Exist
71
+DIM SHARED t 'time
72
+DIM SHARED rockX
73
+DIM SHARED rockY
74
+DIM SHARED startRockXvel
75
+DIM SHARED startRockYvel
76
+DIM SHARED gravity
77
+DIM SHARED wind
78
+
79
+'The castles and tank.
80
+DIM SHARED castle2X
81
+DIM SHARED castleX
82
+DIM SHARED TankExist
83
+DIM SHARED TankX
84
+DIM SHARED oldTankX
85
+DIM SHARED tankSpeed
86
+DIM SHARED castleExist
87
+DIM SHARED Castle2Exist
88
+
89
+DIM SHARED x1 AS INTEGER, y1 AS INTEGER, x2 AS INTEGER, y2 AS INTEGER
90
+DIM SHARED TKills AS INTEGER, ShotsFired AS INTEGER, GameType AS INTEGER
91
+DIM SHARED Castle2Hits AS INTEGER
92
+DIM SHARED ExplodeHold(1 TO 10000)  AS INTEGER
93
+
94
+castleExist=1
95
+Castle2Exist=1
96
+
97
+SCREEN 13
98
+
99
+GameType=1
100
+menu:
101
+CLS
102
+PRINT TAB(10); "QBasic RockWars v1.1"
103
+PRINT TAB(10); " By Brennen Bearnes"
104
+PRINT
105
+PRINT TAB(10); "1. Game Options"
106
+PRINT TAB(10); "2. Start Game"
107
+PRINT TAB(10); "3. Quit"
108
+DO
109
+LOCATE 7, 10: INPUT ">", menud
110
+LOOP UNTIL menud >=1 AND menud <= 3
111
+SELECT CASE menud
112
+CASE 1
113
+PRINT
114
+INPUT "Gravity (9.8 Default): ", gravinput
115
+PRINT
116
+PRINT "Game type:"
117
+PRINT "1. Red Castle can be destroyed,"
118
+PRINT "   unlimited tanks."
119
+PRINT
120
+PRINT "2. Red Castle cannot be destroyed,"
121
+PRINT "   limited tanks."
122
+PRINT
123
+PRINT "3. Red Castle takes several hits to"
124
+PRINT "   destroy, limited tanks."
125
+PRINT
126
+INPUT ">", GameType
127
+IF GameType > 3 THEN GameType=3
128
+IF GameType < 1 THEN GameType=1
129
+GOSUB menu
130
+CASE 2
131
+PRINT
132
+PRINT "While in the game:"
133
+PRINT "F1 to fire"
134
+PRINT "ESC exits"
135
+PRINT
136
+PRINT "Angles can be between 10 and 180."
137
+PRINT "Velocity can be between 0 and 100."
138
+PRINT "Remember to take the wind into account."
139
+PRINT
140
+PRINT "Enjoy!"
141
+SLEEP
142
+CASE 3
143
+GOSUB Qwit
144
+END SELECT
145
+
146
+IF gravinput=0 THEN
147
+gravity=9.8
148
+ELSE
149
+gravity=gravinput
150
+END IF
151
+
152
+'How many hits it takes to kill the red castle, based on GameType
153
+IF GameType=1 THEN
154
+Castle2Hits=1
155
+ELSEIF GameType=2 THEN
156
+Castle2Hits=1
157
+ELSEIF GameType=3 THEN
158
+Castle2Hits=3
159
+END IF
160
+
161
+CLS
162
+
163
+'GET the player's castle.
164
+DIM SHARED castle%(15, 15)
165
+LINE (5, 5)-(20, 20), 1, BF
166
+LINE (8, 5)-(10, 7), 0, BF
167
+LINE (12, 5)-(14, 7), 0, BF
168
+LINE (16, 5)-(18, 7), 0, BF
169
+LINE (10, 15)-(15, 20), 0, BF
170
+GET (5, 5)-(20, 20), castle%
171
+CLS
172
+
173
+'GET the computer's castle.
174
+DIM SHARED castle2%(15, 15)
175
+LINE (5, 5)-(20, 20), 4, BF
176
+LINE (8, 5)-(10, 7), 0, BF
177
+LINE (12, 5)-(14, 7), 0, BF
178
+LINE (16, 5)-(18, 7), 0, BF
179
+LINE (10, 15)-(15, 20), 0, BF
180
+GET (5, 5)-(20, 20), castle2%
181
+CLS
182
+
183
+'GET the tank
184
+DIM SHARED tank%(11, 8)
185
+LINE (2, 4)-(10, 6), 2, BF
186
+LINE (5, 1)-(8, 4), 2, BF
187
+LINE (1, 2)-(5, 2), 2
188
+CIRCLE (3, 6), 2, 2
189
+CIRCLE (8, 6), 2, 2
190
+GET (1, 1)-(11, 8), tank%
191
+CLS
192
+
193
+'The tank firing.
194
+DIM SHARED tank2%(11, 8)
195
+LINE (2, 4)-(10, 6), 2, BF
196
+LINE (5, 1)-(8, 4), 2, BF
197
+LINE (1, 1)-(5, 3), 2
198
+CIRCLE (3, 6), 2, 2
199
+CIRCLE (8, 6), 2, 2
200
+GET (1, 1)-(11, 8), tank2%
201
+CLS
202
+
203
+'The center of the planet
204
+planetX=180: planetY = 45
205
+'Draw the planet
206
+FOR circ%=1 TO 8
207
+CIRCLE (planetX, planetY), circ%, 9
208
+CIRCLE (planetX, planetY + 1), circ%, 9
209
+NEXT circ%
210
+LINE (planetX - 8, planetY)-(planetX + 8, planetY), 4
211
+LINE (planetX - 8, planetY - 2)-(planetX + 8, planetY - 2), 12
212
+LINE (planetX - 7, planetY - 3)-(planetX + 7, planetY - 3), 12
213
+LINE (planetX - 5, planetY - 5)-(planetX + 5, planetY - 5), 4
214
+LINE (planetX - 8, planetY + 3)-(planetX + 8, planetY + 3), 4
215
+LINE (planetX - 6, planetY + 5)-(planetX + 6, planetY + 5), 4
216
+CIRCLE (planetX + 2, planetY + 4), 2, 4
217
+CIRCLE (planetX + 2, planetY + 4), 1, 4
218
+CIRCLE (planetX + 3, planetY + 4), 1, 4
219
+
220
+'Draw the ground
221
+LINE (0, 175)-(320, 175), 10
222
+PAINT (0, 176), 10, 1
223
+
224
+'PUT the castles
225
+castleX=15
226
+PUT (castleX, 159), castle%
227
+RANDOMIZE TIMER
228
+castle2X=INT(RND * 175) + 175
229
+IF castle2X >=285 THEN castle2X = 285
230
+PUT (castle2X, 159), castle2%
231
+
232
+'The code to make the moon "orbit" the planet was done by Marco Koegler
233
+orbitRadius=30 'Radius of the orbit
234
+moonAngle=0 'Initialize the moons angle
235
+oldMoonX=planetX + 75: oldMoonY = planetY
236
+
237
+'Display stars
238
+FOR cnt%=1 TO 75
239
+PSET (INT(RND * 319), INT(RND * 120) + 30), INT(RND * 15 + 15)
240
+NEXT cnt%
241
+
242
+'This is the main program loop.
243
+DO
244
+moonAngle=moonAngle + .5
245
+IF moonAngle=360 THEN moonAngle = 0
246
+theta=moonAngle * (pi / 180)
247
+moonX=planetX + orbitRadius * (COS(theta))
248
+moonY=planetY - orbitRadius * (SIN(theta))
249
+
250
+'Erase old moon
251
+CIRCLE (oldMoonX, oldMoonY), 2, 0
252
+
253
+'Draw new moon
254
+CIRCLE (moonX, moonY), 2, 8
255
+oldMoonX=moonX: oldMoonY = moonY
256
+
257
+ptime!=TIMER: WHILE ptime! = TIMER: WEND ' Pause
258
+
259
+K$=INKEY$
260
+IF LEN(K$)=2 THEN
261
+SELECT CASE ASC(RIGHT$(K$, 1))
262
+CASE 59 'F1
263
+IF Rock1Exist=0 THEN
264
+newRock
265
+END IF
266
+END SELECT
267
+ELSEIF LEN(K$)=1 THEN
268
+SELECT CASE ASC(K$)
269
+CASE 27: quit=1
270
+END SELECT
271
+END IF
272
+
273
+IF Rock1Exist=1 THEN
274
+drawRock
275
+END IF
276
+
277
+IF TankExist=0 AND Castle2Exist = 1 THEN
278
+newTank
279
+ELSEIF TankExist=1 THEN
280
+drawTank
281
+END IF
282
+
283
+'Check and see if the player has won or lost yet...
284
+IF castleExist=0 THEN
285
+'"Melt" the screen and end the game if the player loses.
286
+quit=2
287
+END IF
288
+
289
+IF GameType=1 AND Castle2Exist = 0 AND TankExist = 0 THEN
290
+quit=3
291
+ELSEIF GameType=2 AND TKills >= 20 THEN
292
+quit=4
293
+ELSEIF GameType=3 THEN
294
+IF TKills >=20 THEN
295
+quit=4
296
+END IF
297
+IF Castle2Exist=0 AND TankExist = 0 THEN
298
+quit=3
299
+END IF
300
+END IF
301
+
302
+LOOP UNTIL quit > 0
303
+'End of main program loop.
304
+
305
+'The game now prints out your score at the end.  Makes it seem like you've
306
+'accomplished something.  Or not.
307
+'One shot is subtracted from ShotsFired if you destroy the red castle.
308
+'seems only fair.
309
+
310
+IF quit=2 THEN 'The ending if you lose.
311
+'"Melt" the screen and end the game if the player loses.
312
+LOCATE 8, 15: PRINT "you lose"
313
+LOCATE 9, 14: PRINT "the end"
314
+LOCATE 14, 10: PRINT "tanks killed: "; TKills
315
+LOCATE 15, 10: PRINT "rocks fired: "; ShotsFired
316
+IF TKills >=1 THEN
317
+LOCATE 16, 10: PRINT "shots per kill: "; ShotsFired / TKills
318
+END IF
319
+SLEEP 2
320
+DIM melt%(3000)
321
+FOR RR=1 TO 3000
322
+RANDOMIZE TIMER
323
+XX=INT(RND * 271)
324
+RANDOMIZE TIMER
325
+YX=INT(RND * 150)
326
+GET (XX, YX)-(XX + 48, YX + 48), melt%
327
+PUT (XX, YX + 1), melt%, PSET
328
+IF INKEY$=CHR$(27) THEN END
329
+NEXT RR
330
+ELSEIF quit=3 THEN
331
+'The ending if you kill both the tank and castle (Game types 1 and 3).
332
+LOCATE 13, 15: PRINT "you win"
333
+LOCATE 14, 10: PRINT "tanks killed: "; TKills
334
+LOCATE 15, 10: PRINT "rocks fired: "; ShotsFired
335
+LOCATE 16, 10: PRINT "shots per kill: "; ShotsFired / TKills
336
+ELSEIF quit=4 THEN 'The ending if you kill all the tanks.
337
+LOCATE 12, 5: PRINT "The red castle has no tanks left."
338
+LOCATE 13, 5: PRINT "Victory is yours."
339
+LOCATE 15, 10: PRINT "tanks killed: "; TKills
340
+LOCATE 16, 10: PRINT "rocks fired: "; ShotsFired
341
+LOCATE 17, 10: PRINT "shots per kill: "; ShotsFired / TKills
342
+END IF
343
+
344
+WHILE INKEY$=""
345
+WEND
346
+
347
+CLS
348
+
349
+'Ask player if they want to play again, then send them back to the starting
350
+'menu.
351
+INPUT "Do you want to play again"; menud$
352
+menud$=UCASE$(menud$)
353
+SELECT CASE menud$
354
+CASE "Y"
355
+quit=0
356
+GOSUB Restart
357
+CASE "N"
358
+PRINT "Thanks for playing!"
359
+GOSUB Qwit
360
+END SELECT
361
+
362
+Qwit:
363
+END
364
+
365
+SUB drawRock
366
+
367
+oldRockX=rockX
368
+oldRockY=rockY
369
+
370
+'Calculate the next position of the rock
371
+rockX=startRockX + (startRockXvel * t) + (.5 * (wind / 5) * t ^ 2)
372
+rockY=startRockY + ((-1 * (startRockYvel * t)) + (.5 * gravity * t ^ 2)) * (200 / 350)
373
+
374
+IF rockY >=174 THEN
375
+'Do an explosion when the rock hits the "ground".
376
+Rock1Exist=0
377
+'The below code used to go in front of every explosion, 'til I figured out
378
+'it would be easier to specify the variables when calling the SUB.  I'm a
379
+'little slow sometimes.
380
+'green%=20
381
+'blue%=0
382
+'boomX=rockX
383
+'boomY=rockY
384
+'boomSize=6
385
+explode 20, 0, red%, rockX, rockY, 6
386
+CIRCLE (oldRockX, oldRockY), 1, 0 ' Erase rock
387
+ELSEIF rockY >=159 AND rockX >= castle2X AND rockX <= castle2X + 15 THEN
388
+Rock1Exist=0
389
+CIRCLE (oldRockX, oldRockY), 1, 0 ' Erase rock
390
+IF GameType <> 2 THEN
391
+IF GameType=3 OR GameType = 1 THEN
392
+Castle2Hits=Castle2Hits - 1 'Subtracts 1 hitpoint from castle.
393
+END IF
394
+'Do an explosion if the enemy castle has 0 hit points left
395
+IF Castle2Hits=0 AND Castle2Exist = 1 THEN
396
+ShotsFired=ShotsFired - 1 'Subtract 1 from the players shots fired.
397
+Rock1Exist=0
398
+Castle2Exist=0
399
+explode 0, 0, red%, rockX, rockY, 50
400
+PUT (castle2X, 159), castle2% ' Erase enemy castle
401
+END IF
402
+END IF
403
+ELSEIF rockY >=167 AND rockX >= TankX AND rockX <= TankX + 10 THEN
404
+'Do an explosion if rock hits the tank.
405
+TKills=TKills + 1 'Add 1 to kill counter.
406
+TankExist=0
407
+Rock1Exist=0
408
+explode 20, 0, red%, TankX, rockY, 30
409
+CIRCLE (oldRockX, oldRockY), 1, 0 ' Erase rock
410
+PUT (INT(TankX), 167), tank%, XOR ' Erase tank
411
+END IF
412
+
413
+IF rockX >=319 OR rockX <= 1 THEN
414
+Rock1Exist=0
415
+CIRCLE (oldRockX, oldRockY), 1, 0
416
+END IF
417
+
418
+IF Rock1Exist=1 THEN
419
+CIRCLE (oldRockX, oldRockY), 1, 0
420
+CIRCLE (rockX, rockY), 1, 12
421
+ELSEIF Rock1Exist=0 THEN
422
+rockX=0
423
+rockY=0
424
+END IF
425
+
426
+t=t + .1
427
+
428
+END SUB
429
+
430
+SUB drawTank
431
+
432
+'Move the tank, or if the tank is close enough, blow up the player's
433
+'castle.
434
+tankSpeed=.5
435
+IF TankX > castleX + 60 THEN
436
+'Make the tank try to avoid the rocks (doesn't work very well, but can
437
+'make the game a little more challenging).
438
+IF TankX - rockX < 20 AND TankX - rockX > -1 THEN
439
+tankSpeed=-.8
440
+END IF
441
+oldTankX=TankX
442
+TankX=TankX - tankSpeed
443
+ELSEIF TankX <=castleX + 60 THEN
444
+PUT (INT(TankX), 167), tank2%, PSET
445
+SLEEP 1
446
+PALETTE 95, 60
447
+LINE (INT(TankX) - 2, 167)-(castleX + 15, 162), 95
448
+FOR cnt%=1 TO 30
449
+PALETTE 95, INT(RND * 30 + 30)
450
+ptime!=TIMER: WHILE ptime! = TIMER: WEND ' Pause
451
+NEXT cnt%
452
+PALETTE 95, 0
453
+TankExist=0
454
+explode 0, 30, red%, castleX + 15, 162, 50
455
+castleExist=0
456
+END IF
457
+
458
+PUT (INT(oldTankX), 167), tank%, XOR
459
+PUT (INT(TankX), 167), tank%, PSET
460
+
461
+END SUB
462
+
463
+SUB explode (green%, blue%, red%, boomX, boomY, boomSize)
464
+
465
+'This code started as EXPLODE.BAS by Brent P. Newhall.  I've only made a
466
+'few minor changes.  The comments are all his.
467
+
468
+''I was thinking about that "I need fire and an exploding graphic" post
469
+''and came up with this simple explosion program.  Any suggestions,
470
+''comments, etc. are welcome with open arms.
471
+
472
+''NOTES: There are two lines that do not wrap properly; you'll be able to
473
+''find them easily.  Also, NumArcs is set to 100, which does an
474
+''acceptable explosion on my 486DX2/50 with 8 megs of RAM.  You Pentium
475
+''people should be able to get a much nicer explosion if you set NumArcs
476
+''equal to 1000 or so.
477
+
478
+''The program sets colors 100 to 131 to varying shades of red, orange,
479
+''and yellow for the explosive effect, with the nice side-effect that
480
+'you can theoretically do several explosions at once.
481
+
482
+NumArcs=65
483
+DIM arc(1 TO NumArcs) AS arctype
484
+RANDOMIZE TIMER
485
+FOR cnt%=1 TO NumArcs ' Initialise
486
+arc(cnt%).Radius=0
487
+arc(cnt%).p1=RND * 5.8
488
+arc(cnt%).p2=arc(cnt%).p1 + (RND / 2)
489
+arc(cnt%).colr=INT(RND * 5 + 100)
490
+NEXT cnt%
491
+red%=63 ' Start it deep red
492
+FOR cnt%=100 TO 130 ' Change colors
493
+PALETTE cnt%, red% + 256 * green% + 65536 * blue%
494
+IF cnt% <=114 THEN ' Lower red, increase yellow
495
+red%=red% - 2
496
+green%=green% + 2
497
+ELSE ' Lower red and yellow
498
+red%=red% - 2
499
+green%=green% - 2
500
+END IF
501
+NEXT cnt%
502
+PALETTE 131, 0
503
+TimeCnt%=0
504
+x1=boomX - boomSize
505
+IF x1 < 0 THEN x1=0
506
+y1=boomY - boomSize
507
+IF y1 < 0 THEN y1=0
508
+x2=boomX + boomSize
509
+IF x2 > 319 THEN x2=319
510
+y2=boomY + boomSize
511
+IF y2 > 199 THEN y2=199
512
+GET (x1, y1)-(x2, y2), ExplodeHold(1)
513
+DO
514
+TimeCnt%=TimeCnt% + 1
515
+FOR CurrArc%=1 TO NumArcs
516
+IF arc(CurrArc%).Radius > 4 THEN ' Erase previous arc
517
+CIRCLE (boomX, boomY), arc(CurrArc%).Radius - 5, 0, arc(CurrArc%).p1, arc(CurrArc%).p2
518
+END IF
519
+IF arc(CurrArc%).Radius=0 THEN ' Not yet alive
520
+' About 30% of the time, create a new arc
521
+IF RND > .7 THEN arc(CurrArc%).Radius=1
522
+ELSEIF arc(CurrArc%).colr=131 THEN ' Dead
523
+REM Do Nothing
524
+ELSE
525
+arc(CurrArc%).Radius=arc(CurrArc%).Radius + 1 ' Increase radius
526
+arc(CurrArc%).colr=arc(CurrArc%).colr + 1 ' Increase color
527
+' Draw arc
528
+CIRCLE (boomX, boomY), arc(CurrArc%).Radius, arc(CurrArc%).colr, arc(CurrArc%).p1, arc(CurrArc%).p2
529
+END IF
530
+NEXT CurrArc%
531
+t!=TIMER: WHILE t! = TIMER: WEND ' Pause
532
+IF TimeCnt% >=boomSize THEN quitExplode = 1
533
+LOOP UNTIL quitExplode > 0
534
+PUT (x1, y1), ExplodeHold(1), PSET
535
+
536
+END SUB
537
+
538
+SUB newRock
539
+
540
+'Add 1 to shots fired counter.
541
+ShotsFired=ShotsFired + 1
542
+
543
+'initialize the wind, and tell the player.
544
+RANDOMIZE TIMER: windirec=RND * 2:
545
+LOCATE 1, 1: PRINT SPC(30);
546
+IF windirec <=1 THEN
547
+RANDOMIZE TIMER: wind=RND * -10
548
+LOCATE 1, 1: PRINT "wind: "; wind; " "
549
+ELSEIF windirec > 1 THEN
550
+RANDOMIZE TIMER: wind=RND * 10
551
+LOCATE 1, 1: PRINT "wind:"; wind; "  "
552
+END IF
553
+
554
+'Get player input for angle and velocity, and initialize the rock.
555
+'Velocity can range from 0 to 100, and angle can be in between 10 and 180.
556
+
557
+LOCATE 2, 1: PRINT "Angle:   "
558
+DO
559
+LOCATE 2, 7: PRINT "    ";
560
+LOCATE 2, 7: INPUT "", rockAngle
561
+LOOP UNTIL rockAngle >=10 AND rockAngle <= 180
562
+LOCATE 3, 1: PRINT "Velocity:   "
563
+DO
564
+LOCATE 3, 10: PRINT "    ";
565
+LOCATE 3, 10: INPUT "", rockSpeed
566
+LOOP UNTIL rockSpeed >=0 AND rockSpeed <= 100
567
+
568
+LINE (1, 1)-(50, 50), 0
569
+startRockX=castleX + 6
570
+startRockY=157
571
+oldRockX=startRockX
572
+oldRockY=startRockY
573
+Rock1Exist=1
574
+
575
+rockAngle=rockAngle / 180 * pi
576
+startRockXvel=COS(rockAngle) * rockSpeed
577
+startRockYvel=SIN(rockAngle) * rockSpeed
578
+
579
+t=0
580
+
581
+drawRock
582
+
583
+END SUB
584
+
585
+SUB newTank
586
+
587
+'Initialize tank.
588
+TankExist=1
589
+TankX=castle2X - 12
590
+oldTankX=castle2X - 12
591
+
592
+PUT (castle2X, 159), castle2%, PSET
593
+
594
+drawTank
595
+
596
+END SUB