' To start, press Shift+F5. Then type the size (in pixels) of the planets' 'max radii. Type in the number of people playing, and their names. To have 'the computer play a ship press enter for the name. If you give it too many 'players, it does strange things, like making invisible ships. Also, type in 'the number of games to play. ' For each ship (The color of the text being that of the ship) type in the 'angle (in degrees) and the speed of the torpedo. The torpedo can go out of 'the screen, and if the speed is too much (10000 or more), it can pass 'through things. Next choose the type of torpedo to use. You get 500 dollars 'every time you hit someone. To stop the torpedo, and not detonate it, press ''q'. To detonate it in mid flight, press 'd'. If it is a homing bomb, press ''h' to make it home in on the target. To change torpedoes in mid flight, 'press the first letter in the name of the torpedo, 'm' for mega bomb, 's' 'for super bomb, and 'p' for plasma bomb. You can't change to a homing bomb 'in mid flight. ' After only one person is left, 1000 dollars are given to him, and 'everyone buys weapons. ' At the end of the selected number of games, it will give each player a 'score based on the number of times won, and the number of bombs owned. ' You may have some speed problems if your computer isn't top-of-the-line 'since this is Qbasic. It runs fine on my dad's Pentium 166, but on my 'friend's 286, it's impossible to run. ' If you have comments on how I can make it faster, better in general, 'or even just to tell me what you thought about it, then e-mail me at ' 'benjamingarrison@juno.com. ' 'It still has some bugs I can iron out, and if enough people e-mail me saying 'they like it, I'll iron them out, otherwise I won't waste my time. ' 'By the way, you can do whatever you want with this program, and parts of it. DECLARE SUB buys () DECLARE SUB computer (num!) DECLARE SUB drawship (c!, num!) DECLARE SUB makeplanets () DECLARE SUB explode (b, xx!, yy!) COMMON SHARED numofplanets, sofp, angle, speed, pink, x, y, player, typ, ta DIM SHARED planet(20, (4)) RANDOMIZE TIMER CLS COLOR INT(RND * 15) + 1 PRINT " ллллллллллл ллл " PRINT " ллл ллл ллл " PRINT " ллл ллл ллл ллл" PRINT " ллл ллл ллл ллл" PRINT " ллллллллллл ллл лллллллл ллллллллл лллллллл ллллллллл" PRINT " ллл ллл ллл ллл ллл ллл ллл ллл" PRINT " ллл ллл лллллллл ллл ллл лллллллл ллл" PRINT " ллл ллл ллл ллл ллл ллл ллл ллл" PRINT " ллл ллл лллллллл ллл ллл лллллллл ллл" PRINT " " PRINT " ллл ллл" PRINT " ллл ллл" PRINT " ллл ллл" PRINT " ллл ллл ллл лллллллл ллллллллл лллллллл" PRINT " ллл ллл ллл ллл ллл ллл ллл" PRINT " ллл ллл ллл лллллллл ллл лллллллл" PRINT " ллл ллл ллл ллл ллл ллл ллл" PRINT " ллллллллллллллл лллллллл ллл лллллллл" sofp = 70 'Change this to resize planets INPUT "How many players?", pink 'Don't ask WHY I used pink for the number 'of players IF pink < 1 THEN pink = 1 'shippos1 is the x-coordinates of the ships, shippos2 is the y-coordinates DIM SHARED shippos1(pink), shippos2(pink), score(pink), names$(pink), ship(200), bomb(pink), money(pink), arsenal(pink, 4) INPUT "Number of Games: ", nof PRINT "Type in name of each player(a blank means the computer plays)" FOR I = 1 TO pink PRINT "Name of player #"; STR$(I); INPUT names$(I) NEXT I SCREEN 12 FOR I = 0 TO 9 FOR a = 0 TO 19 READ colour PSET (a, I), colour NEXT a NEXT I GET (0, 0)-(20, 10), ship CLS 1 : SCREEN 12 numofplanets = INT(RND * 20) CALL makeplanets FOR c = 1 TO pink CALL drawship(c + 1, c) NEXT c 'My drawing method is derived from the graphics tutorial by Mallard DATA 00,15,15,15,15,15,15,15,15,15,00,00,00,00,00,00,00,00,00,00 DATA 00,15,15,15,15,15,15,15,15,15,00,00,15,15,15,00,00,00,00,00 DATA 00,00,00,00,00,15,00,00,00,00,00,15,15,15,15,15,00,00,00,00 DATA 00,00,00,00,00,15,15,00,00,00,15,15,15,15,15,15,15,00,00,00 DATA 00,00,00,00,15,15,15,15,15,15,15,15,15,15,15,15,15,00,00,00 DATA 00,00,00,00,15,15,15,15,15,15,15,15,15,15,15,15,15,00,00,00 DATA 00,00,00,00,00,15,15,00,00,00,15,15,15,15,15,15,15,00,00,00 DATA 00,00,00,00,00,15,00,00,00,00,00,15,15,15,15,15,00,00,00,00 DATA 00,15,15,15,15,15,15,15,15,15,00,00,15,15,15,00,00,00,00,00 DATA 00,15,15,15,15,15,15,15,15,15,00,00,00,00,00,00,00,00,00,00 player = 1 20 : IF player = pink + 1 THEN player = 1 player = player + 1 IF shippos1(player - 1) = 0 THEN GOTO 20 'If player is dead, choose speed1 = 0 'next player speed2 = 0 typ = 1 IF names$(player - 1) = "" THEN CALL computer(player - 1) IF arsenal(player - 1, 1) > 0 THEN typ = 2 IF arsenal(player - 1, 2) > 0 THEN typ = 3 IF arsenal(player - 1, 3) > 0 THEN typ = 4 ELSE 5 : IF arsenal(player - 1, 1) + arsenal(player - 1, 2) + arsenal(player - 1, 3) + arsenal(player - 1, 4) = 0 THEN GOTO 100 LOCATE 27 COLOR player PRINT names$(player - 1); ", you have: "; STR$(arsenal(player - 1, 1)); " mega bombs(#1), "; STR$(arsenal(player - 1, 2)); " superbombs(#2)" PRINT STR$(arsenal(player - 1, 3)); " plasma bombs(#3), and "; STR$(arsenal(player - 1, 4)); " homing bombs(#4). Enter is normal." DO a$ = INKEY$ LOOP WHILE a$ = "" LOCATE 27 PRINT STRING$(80, " ") PRINT STRING$(80, " ") LOCATE 27 typ = VAL(a$) IF typ > 4 THEN GOTO 5 typ = typ + 1 IF typ = 1 THEN GOTO 100 IF arsenal(player - 1, typ - 1) < 1 THEN GOTO 5 arsenal(player - 1, typ - 1) = arsenal(player - 1, typ - 1) - 1 IF typ = 5 THEN 9 : LOCATE 27 INPUT "Name of target", targt$ LOCATE 27 PRINT STRING$(80, " ") FOR I = 1 TO pink IF names$(I) = targt$ THEN trgt = I NEXT I IF trgt = 0 THEN GOTO 9 END IF 100 : LOCATE 27 IF player < 16 THEN COLOR player PRINT names$(player - 1); ": angle:"; INPUT "", a$ INPUT "Speed:", s$ IF UCASE$(s$) = "B" THEN GOTO 100 ' 'b' redoes the angle IF UCASE$(a$) = "Q" OR UCASE$(s$) = "Q" THEN GOTO 1 LOCATE 27 PRINT STRING$(80, " ") 'Clear text so torpedo won't hit it PRINT STRING$(80, " ") angle = VAL(a$) speed = VAL(s$) angle = angle * 3.14159265358# / 180 'Convert from degrees to radians IF COS(angle) < 0 THEN x = shippos1(player - 1) - 1 y = shippos2(player - 1) + 5 'Decide where the torpedo will come out ELSE x = shippos1(player - 1) + 21 y = shippos2(player - 1) + 5 END IF END IF speed = speed / 100 speed1 = speed * COS(angle) 'use the speed and angle to get the speed2 = -speed * SIN(angle) 'vertical and lateral direction of 'the torpedo DO x = x + speed1 'Change the current position of the torpedo y = y + speed2 'Check to see if there is a pixel on in between the current and last positions FOR I = 100 TO 1 STEP -1 IF names$(player - 1) = "" AND INT(I / 5) = I / 5 THEN LINE (x - speed1 * I / 100, y - speed2 * I / 100)-(x - speed1, y - speed2), 1 IF ((shippos1(ta) - x + speed1 * I / 100) ^ 2 + (shippos2(ta) - y + speed2 * I / 100) ^ 2) ^ .5 < ((shippos1(ta) - x + speed1 * (I - 1) / 100) ^ 2 + (shippos2(ta) - y + speed2 * (I - 1) / 100) ^ 2) ^ .5 THEN GOTO 14 END IF IF POINT(x - speed1 * I / 100, y - speed2 * I / 100) > 1 THEN LINE (x - speed1 * I / 100, y - speed2 * I / 100)-(x - speed1, y - speed2), 1 GOTO 14 END IF NEXT I LINE (x - speed1, y - speed2)-(x, y), 1 'See how much the planets are pulling on the torpedo FOR t = 1 TO numofplanets d = ((x - planet(t, 1)) ^ 2 + (y - planet(t, 2)) ^ 2) ^ .5 speed1 = speed1 - 1 / d ^ 2 * planet(t, 3) ^ 3 / (100) * (x - planet(t, 1)) / d speed2 = speed2 - 1 / d ^ 2 * planet(t, 3) ^ 3 / (100) * (y - planet(t, 2)) / d NEXT t fg$ = INKEY$ IF typ = 5 AND UCASE$(fg$) = "H" THEN d = ((x - shippos1(trgt) - 10) ^ 2 + (y - shippos2(trgt) - 5) ^ 2) ^ .5 speed1 = -1 / d ^ 2 * 30000 * (x - shippos1(trgt) - 10) / d speed2 = -1 / d ^ 2 * 30000 * (y - shippos2(trgt) - 5) / d END IF IF UCASE$(fg$) = "P" AND arsenal(player - 1, 3) > 0 THEN typ = 4 IF UCASE$(fg$) = "S" AND arsenal(player - 1, 2) > 0 THEN typ = 3 IF UCASE$(fg$) = "M" AND arsenal(player - 1, 1) > 0 THEN typ = 2 IF UCASE$(fg$) = "N" THEN typ = 1 LOOP UNTIL UCASE$(fg$) = "Q" OR UCASE$(fg$) = "D" IF UCASE$(fg$) = "Q" THEN GOTO 20 14 : CALL explode(typ, x - speed1 * I / 100, y - speed2 * I / 100) FOR qsc = 1 TO pink IF shippos1(qsc) <> 0 THEN 'Check to see how many players wsx = qsc 'are left, if only one then end FOR qscx = qsc + 1 TO pink IF shippos1(qscx) <> 0 THEN GOTO 20 NEXT qscx END IF NEXT qsc yj = yj + 1 money(wsx) = money(wsx) + 1000 score(wsx) = score(wsx) + 1 IF yj < nof THEN CALL buys IF yj <> nof THEN GOTO 1 SCREEN 0 CLS 'Print players' score in color FOR I = 1 TO pink IF I < 15 THEN COLOR I + 1 scr = money(I) + arsenal(I, 1) * 500 + arsenal(I, 2) * 1000 + arsenal(I, 3) * 2000 + arsenal(I, 4) * 1000 + score(I) * 2000 IF names$(I) = "" THEN PRINT "Computer's score is " + STR$(scr) ELSE PRINT names$(I) + "'s score is " + STR$(scr) END IF NEXT I SUB buys SCREEN 0 FOR q = 1 TO pink 7 : CLS IF money(q) < 500 THEN GOTO 8 PRINT names$(q); ", you have "; money(q); " dollars." PRINT "What do you want to buy?" PRINT "A (m)ega bomb at 500$" PRINT "A (s)uper bomb at 1000$" PRINT "A (p)lasma bomb at 2000$" PRINT "A (h)oming bomb at 1000$" PRINT "(N)othing" IF names$(q) <> "" THEN INPUT "What do you want to buy?", buy$ ELSE IF money(q) > 1999 THEN buy$ = "p" IF money(q) > 999 AND money(q) < 2000 THEN buy$ = "s" IF money(q) > 499 AND money(q) < 1000 THEN buy$ = "m" END IF IF UCASE$(buy$) = "M" AND money(q) > 499 THEN money(q) = money(q) - 500 arsenal(q, 1) = arsenal(q, 1) + 1 END IF IF UCASE$(buy$) = "S" AND money(q) > 999 THEN money(q) = money(q) - 1000 arsenal(q, 2) = arsenal(q, 2) + 1 END IF IF UCASE$(buy$) = "P" AND money(q) > 1999 THEN money(q) = money(q) - 2000 arsenal(q, 3) = arsenal(q, 3) + 1 END IF IF UCASE$(buy$) = "H" AND money(q) > 999 THEN money(q) = money(q) - 1000 arsenal(q, 4) = arsenal(q, 4) + 1 END IF IF UCASE$(buy$) = "N" THEN GOTO 8 GOTO 7 8 : NEXT q END SUB SUB computer (num) w: ta = INT(RND * pink + 1) 'Choose target IF ta = num OR shippos1(ta) = 0 THEN GOTO w 'If target is dead or yourself, IF shippos1(num) > shippos1(ta) THEN 'choose another target x = shippos1(player - 1) - 1 y = shippos2(player - 1) + 5 d = -1 ELSE x = shippos1(player - 1) + 21 y = shippos2(player - 1) + 5 d = 21 END IF 'The arctanget only gives a value between -90 and 90, so I had to figure out 'if it was more than that IF shippos1(num) + d > shippos1(ta) + 10 THEN r = 3.14159265358# angle = ATN(-((shippos2(ta) + 5) - (shippos2(num) + 5)) / ((shippos1(ta) + 10) - (shippos1(num) + d))) + r speed = 10000 IF bomb(num) < 1 THEN typ = 1 ELSE typ = 2 bomb(num) = bomb(num) - 1 END IF END SUB SUB drawship (c, num) 11 : RESTORE shippos1(num) = (RND * 619) 'X position of the ship shippos2(num) = (RND * 399) 'Y position of the ship FOR I = 0 TO 9 'Check to see if you are putting the ship FOR a = 0 TO 19 'on something IF POINT(shippos1(num) + a, shippos2(num) + I) <> 0 THEN GOTO 11 NEXT a NEXT I PUT (shippos1(num), shippos2(num)), ship PAINT (shippos1(num) + 6, shippos2(num)), c, 0 'Fill the ship with it's color END SUB SUB explode (b, xx, yy) IF b = 5 THEN b = 2 I = 1 FOR I = 1 TO 25 * b STEP .1 * b r = INT(RND * 2) IF r THEN cr = 14 ELSE cr = 12 END IF CIRCLE (xx, yy), I, cr PAINT (xx, yy), cr NEXT I CIRCLE (xx, yy), 25 * b, 0 FOR I = 1 TO 100 / b r = INT(RND * 2) IF r THEN cr = 14 ELSE cr = 12 END IF PAINT (xx, yy), cr, 0 NEXT I CIRCLE (xx, yy), 25 * b, 1 PAINT (xx, yy), 0, 1 CIRCLE (xx, yy), 25 * b, 0 FOR w = 1 TO pink RESTORE dead = 0 FOR y1 = 0 TO 9 FOR x1 = 0 TO 19 READ jh IF jh = 15 THEN jh = w + 1 IF POINT(shippos1(w) + x1, shippos2(w) + y1) <> jh THEN dead = 1 NEXT x1 NEXT y1 IF dead = 1 THEN IF shippos1(w) = 0 THEN GOTO 4 FOR I = 0 TO 9 FOR a = 0 TO 19 PSET (shippos1(w) + a, shippos2(w) + I), 0 NEXT a NEXT I money(player - 1) = money(player - 1) + 500 shippos1(w) = 0 END IF 4 : NEXT w END SUB SUB makeplanets CLS FOR I = 1 TO numofplanets 'Set planet color planet(I, 4) = INT(RND * 13) + 2 NEXT I FOR I = 1 TO numofplanets 'Draw each planet, checking if it's 3 : planet(I, 1) = INT(RND * 640) 'on another one planet(I, 2) = INT(RND * (420 - sofp)) planet(I, 3) = INT(RND * sofp) FOR r = 1 TO I - 1 IF ((planet(r, 1) - planet(I, 1)) ^ 2 + (planet(r, 2) - planet(I, 2)) ^ 2) ^ .5 < planet(I, 3) + planet(r, 3) THEN GOTO 3 NEXT r CIRCLE (planet(I, 1), planet(I, 2)), planet(I, 3), planet(I, 4) PAINT (planet(I, 1), planet(I, 2)), planet(I, 4) NEXT I END SUB