PUBLIC WShell, WSmallDirt, WLargeDir, WBounce WShell = 1 WSmallDirt = 2 WLargeDirt = 3 WBounce = 4 ' ========================== ' ** Initialize Variables ** ' ========================== DIM tankx(2) ' Tank X Position DIM tanky(2) ' Tank Y Position DIM turrx(2) ' Turret X Position DIM turry(2) ' Turret Y Position DIM turrang(2) ' Angle of Turret DIM turroang(2) ' Old Angle of Turret DIM power(2) ' Power Store DIM weapon(2) ' Current Weapon DIM weap$(4) weap$(1) = "Shell" weap$(2) = "Small Dirt" weap$(3) = "Large Dirt" weap$(4) = "Bouncer" maxdebris = 50 DIM debris(maxdebris) DIM debrisx(maxdebris) DIM debrisy(maxdebris) DIM debrisox(maxdebris) DIM debrisoy(maxdebris) DIM debrisvx(maxdebris) DIM debrisvy(maxdebris) DIM debriscl(maxdebris) grav = .2 changey = 20 changex = 8 wind = 0 SCREEN 9 CLS ' ======================== ' ** Generate Landscape ** ' ======================== COLOR 0 CLS y = 200 RANDOMIZE TIMER FOR X = 0 TO 641 STEP changex a = INT(RND(1) * 2) IF a = 1 THEN y2 = y + INT(RND(1) * changey) ELSE y2 = y - INT(RND(1) * changey) END IF IF y2 > 340 THEN y2 = 340 LINE (X, y)-(X + changex, y2), 2 y = y2 NEXT X PAINT (1, 300), 2, 2 ' ================== ' ** Set up Tanks ** ' ================== turroang(1) = 90: turroang(2) = 270 turrang(1) = 90: turrang(2) = 270 weapon(1) = WShell: weapon(2) = WShell GOSUB FindGround1 GOSUB FindGround2 GOSUB DrawTanks player = 1 DO fire = 0 pow = power(player) ' ================= ' ** Random Wind ** ' ================= RANDOMIZE TIMER b = INT(RND(1) * 4) IF b = 1 THEN wind = 0 ELSE a = INT(RND(1) * 2) IF a = 1 THEN wind = RND(1) * 3 ELSE wind = -(RND(1) * 3) END IF END IF GOSUB status DO ky$ = INKEY$ ' ================= ' ** Key Control ** ' ================= IF ky$ <> "" THEN SELECT CASE ky$ CASE "," turroang(player) = turrang(player) turrang(player) = turrang(player) + 5 IF turrang(player) > 270 THEN turrang(player) = 270 GOSUB drawturret GOSUB status CASE "." turroang(player) = turrang(player) turrang(player) = turrang(player) - 5 IF turrang(player) < 90 THEN turrang(player) = 90 GOSUB drawturret GOSUB status CASE "=", "+" pow = pow + 5 IF pow > 300 THEN pow = 300 GOSUB status CASE "-" pow = pow - 5 IF pow < 0 THEN pow = 0 GOSUB status CASE CHR$(13) fire = 1 CASE CHR$(32) weapon(player) = weapon(player) + 1 IF weapon(player) > UBOUND(weap$) THEN weapon(player) = 1 GOSUB status CASE CHR$(27) SCREEN 0,0,0 END END SELECT END IF LOOP UNTIL fire = 1 power(player) = pow ' ====================================== ' ** Work out initial bullet position ** ' ====================================== IF player = 1 THEN X = 10 y = tanky(1) - 4 ELSE X = 630 y = tanky(2) - 4 END IF ' ============================== ' ** Work out bullet velocity ** ' ============================== pow = pow / 10 ang = turrang(player) bullx = X + 10 * SIN(ang * (3.14 / 180)) bully = y + 10 * COS(ang * (3.14 / 180)) bullvx = pow * SIN(ang * (3.14 / 180)) bullvy = pow * COS(ang * (3.14 / 180)) movebullet = 1 DO ' =========================== ' ** Draw Bullet in Flight ** ' =========================== IF movebullet = 1 THEN CIRCLE (bullox, bulloy), 1, 0 bullox = bullx: bulloy = bully bullvx = bullvx + (wind / 10) bullx = bullx + bullvx bullvy = bullvy + grav bully = bully + bullvy IF bullx < 1 THEN bullx = 1 bullvx = -bullvx END IF IF bullx > 640 THEN bullx = 640 bullvx = -bullvx END IF IF POINT(bullox, bulloy) <> 0 AND bully > 12 THEN hittank = 0 SELECT CASE POINT(bullox, bulloy) CASE 2 SELECT CASE weapon(player) CASE WShell FOR f = 0 TO 15 STEP .5 CIRCLE (bullox, bulloy), f, 0 NEXT f GOSUB makedebris CASE WSmallDirt GOSUB makedebris FOR f = 0 TO 10 STEP .5 CIRCLE (bullox, bulloy), f, 2 NEXT f CASE WLargeDirt GOSUB makedebris FOR f = 0 TO 20 STEP .5 CIRCLE (bullox, bulloy), f, 2 NEXT f CASE WBounce IF bullvy >= 2 THEN bullvy = -bullvy bully = bully - 8 ELSE GOSUB makedebris FOR f = 0 TO 25 STEP .5 CIRCLE (bullox, bulloy), f, 0 NEXT f END IF END SELECT CASE 15 hittank = 1 GOSUB makedebris END SELECT ELSE CIRCLE (bullx, bully), 1, 15 END IF IF bully > 400 THEN EXIT DO END IF END IF ' ============ ' ** Debris ** ' ============ debris = 0 FOR f = 0 TO maxdebris IF debris(f) = 1 THEN debris = debris + 1 ' Move Debris: CIRCLE (debrisox(f), debrisoy(f)), 1, 0 debrisox(f) = debrisx(f): debrisoy(f) = debrisy(f) debrisvx(f) = debrisvx(f) + (wind / 10) debrisvy(f) = debrisvy(f) + grav debrisx(f) = debrisx(f) + debrisvx(f) debrisy(f) = debrisy(f) + debrisvy(f) ' Get rid of debris/draw debris: IF (POINT(debrisx(f), debrisy(f)) = 2) OR debrisx(f) < 1 OR debrisx(f) > 640 OR debrisy(f) > 390 THEN debris(f) = 0 CIRCLE (debrisox(f), debrisoy(f)), 1, 0 ELSE CIRCLE (debrisx(f), debrisy(f)), 1, debriscl(f) END IF END IF NEXT f FOR f = 1 TO 500: NEXT f LOOP UNTIL debris = 0 AND explosion = 1 IF POINT(tankx(1), tanky(1) + 5) = 0 THEN GOSUB EraseTank1 GOSUB FindGround1 END IF IF POINT(tankx(2), tanky(2) + 5) = 0 THEN GOSUB EraseTank2 GOSUB FindGround2 END IF GOSUB DrawTanks explosion = 0 IF player = 1 THEN player = 2 ELSE player = 1 END IF LOOP END ' ================= ' ** Draw Turret ** ' ================= drawturret: IF player = 1 THEN X = tankx(1) y = tanky(1) - 4 ELSE X = tankx(2) y = tanky(2) - 4 END IF x2 = X + 7 * SIN(turroang(player) * (3.14 / 180)) y2 = y + 7 * COS(turroang(player) * (3.14 / 180)) LINE (X, y)-(x2, y2), 0 x2 = X + 7 * SIN(turrang(player) * (3.14 / 180)) y2 = y + 7 * COS(turrang(player) * (3.14 / 180)) LINE (X, y)-(x2, y2), 7 RETURN ' ========================= ' ** Draw Status Display ** ' ========================= status: COLOR 15 LOCATE 1, 1 PRINT SPACE$(80) LOCATE 1, 1 PRINT "Player:" + LTRIM$(STR$(player)) + " "; PRINT "Angle:" + LTRIM$(STR$(turrang(player))); COLOR 3: PRINT "("; : COLOR 5: PRINT "<"; : COLOR 3: PRINT ","; : COLOR 5: PRINT ">"; : COLOR 3: PRINT ") "; : COLOR 15 PRINT "Power:" + LTRIM$(STR$(pow)); COLOR 3: PRINT "("; : COLOR 5: PRINT "-"; : COLOR 3: PRINT ","; : COLOR 5: PRINT "+"; : COLOR 3: PRINT ") "; : COLOR 15 COLOR 14: PRINT weap$(weapon(player)) + " "; : COLOR 15 IF wind = 0 THEN X$ = "None" ELSE IF wind < 0 THEN X$ = "Westerly" ELSE X$ = "Easterly" END IF IF ABS(wind) <= 1 THEN X$ = "Light " + X$ ELSE IF ABS(wind) <= 2 THEN X$ = "Medium " + X$ ELSE IF ABS(wind) <= 3 THEN X$ = "Strong " + X$ END IF END IF END IF PRINT "Wind: "; : COLOR 5: PRINT X$ RETURN makedebris: movebullet = 0 explosion = 1 FOR f = 0 TO maxdebris RANDOMIZE TIMER a = INT(RND(1) * 2) debrisy(f) = bulloy - INT(RND(1) * 2) IF a = 1 THEN debrisx(f) = bullox + INT(RND(1) * 2) ELSE debrisx(f) = bullox - INT(RND(1) * 2) END IF IF hittank = 1 THEN debrisvx(f) = INT(RND(1) * bullvx) debrisvy(f) = -INT(RND(1) * 9) RANDOMIZE TIMER a = INT(RND(1) * 4) IF a = 1 THEN debriscl(f) = 10 ELSE IF a = 2 THEN debriscl(f) = 15 ELSE IF a = 3 THEN debriscl(f) = 14 ELSE debriscl(f) = 5 END IF END IF END IF ELSE debriscl(f) = 10 RANDOMIZE TIMER debrisvx(f) = INT(RND(1) * bullvx) debrisvy(f) = -INT(RND(1) * 9) END IF debris(f) = 1 NEXT f RETURN DrawTanks: LINE (tankx(1) - 5, tanky(1) - 3)-(tankx(1) + 5, tanky(1)), 15, BF LINE (tankx(2) - 5, tanky(2) - 3)-(tankx(2) + 5, tanky(2)), 15, BF oplayer = player player = 1: GOSUB drawturret player = 2: GOSUB drawturret player = oplayer RETURN ' =========================== ' ** Find Ground for Tanks ** ' =========================== FindGround1: tankx(1) = 10 FOR f = 0 TO 390 IF POINT(tankx(1), f) = 2 THEN tanky(1) = f EXIT FOR END IF NEXT f RETURN FindGround2: tankx(2) = 630 FOR f = 0 TO 390 IF POINT(tankx(2), f) = 2 THEN tanky(2) = f EXIT FOR END IF NEXT f RETURN ' ================= ' ** Erase Tanks ** ' ================= EraseTank1: X = tankx(1) y = tanky(1) - 4 x2 = X + 7 * SIN(turroang(1) * (3.14 / 180)) y2 = y + 7 * COS(turroang(1) * (3.14 / 180)) LINE (X, y)-(x2, y2), 0 LINE (tankx(1) - 5, tanky(1) - 3)-(tankx(1) + 5, tanky(1)), 0, BF RETURN EraseTank2: X = tankx(2) y = tanky(2) - 4 x2 = X + 7 * SIN(turroang(2) * (3.14 / 180)) y2 = y + 7 * COS(turroang(2) * (3.14 / 180)) LINE (X, y)-(x2, y2), 0 LINE (tankx(2) - 5, tanky(2) - 3)-(tankx(2) + 5, tanky(2)), 0, BF RETURN