Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tank Battle - One or Two Player
#1
I originally wrote this program in assembly for the commodore pet in 1979-80ish.
Revised 9/2/25 - Bullets reflect off brown walls, 2 active bullets on the screen per tank at same time.
Revised 9/4/25 - Now utilizes attached controllers and/or keyboard, full screen and a windows font versus the dos font.
Revised 9/9/25 - Biggest revision - Now has AI tank to battle for single player, info screen and full screen is a toggle + other fixes or improvements.
Final Revision 9/14/25 - Third tank added - Use P F and I during game play for interesting toggles.
Revise (lol) 9/21/25 - Now with Two Computer Tanks (Can battle each other) and adjustable speed.
Download the zip file for all supporting files.

Code: (Select All)
$ExeIcon:'./\data\favicon.ico'
'
'
'                      *****  Tank Battle By David Coterel - September 2025  *****
'
' After first coding this game in basic for the Commodore Pet in 1978 and then realizing it was very slow
' I picked up a book and learned assembly and reprogrammed a very basic version of this game in assembly
'    A neighbor friend and I play this game for hours, learning QB64PE I was encouraged to rewrite
'  This game from the old days, it"s been a great trip in the past for me and with the power of qb64PE
'      and today's modern computers, I have added alot of extras, I hope you enjoy playing this game.
'
'
'






$Resize:Smooth
_Title "Tank Battle"

DefInt A-Z
Dim Shared dh, dw
Dim colo As _Unsigned Long
Randomize (-Timer)

dw = _DesktopWidth
dh = _DesktopHeight

If dw < 1024 Or dh < 768 Then Cls: Print "A minimum Screen Resolution of 1024 x 768 is required to play": End
If InStr(_Device$(1), "KEYBOARD") = 0 Then Print "A Keyboard is required": End
If InStr(_Device$(2), "MOUSE") = 0 Then Print "A Mouse is required": End

dw = 1024: dh = 768: fps! = 60

fir& = _SndOpen("data\gun.wav")
ex& = _SndOpen("data\explosion.wav")
tm1& = _SndOpen("data\tm1.wav")
tm2& = _SndOpen("data\tm2.wav")
bu& = _LoadImage("data\bush.png", 32)
br& = _LoadImage("data\brick.png", 32)
bru& = _LoadImage("data\bricku.png", 32)
las& = _SndOpen("data\laser.wav")

Const wh& = _RGB32(255, 255, 255)
Const bl& = _RGB32(0, 0, 0)
Const bor& = _RGB32(155, 100, 255)
Const t1& = _RGB32(255, 255, 0)
Const t2& = _RGB32(0, 255, 0)
Const t3& = _RGB32(11, 55, 194)
Const t31& = _RGB32(175, 0, 0)
Const mi& = _RGB32(255, 0, 0)
Const red& = _RGB32(255, 15, 15)
Const bro& = _RGB32(133, 72, 11)
Const gre& = _RGB32(50, 150, 50)
Const gra& = _RGB32(100, 100, 100)

pls& = _NewImage(dw, dh, 32): _Dest pls&: Cls
Line (15, 15)-(dw - 16, dh - 16), bor&, B: Paint (3, 3), bor&, bor&
Line (59, 59)-(dw - 60, dh - 60), bro&, B: Line (79, 79)-(dw - 79, dh - 79), bro&, B: Paint (61, 61), bro&, bro&
Line (20, 139)-(dw - 20, dh - 140), bl&, BF: Line (139, 20)-(dw - 140, dh - 21), bl&, BF
Line (206, 192)-(306, 242), bro&, BF: Line (226, 192)-(286, 222), bl&, BF
Line (dw - 307, 192)-(dw - 207, 242), bro&, BF: Line (dw - 287, 192)-(dw - 227, 222), bl&, BF
Line (206, dh - 243)-(306, dh - 193), bro&, BF: Line (226, dh - 223)-(286, dh - 193), bl&, BF
Line (dw - 307, dh - 243)-(dw - 207, dh - 193), bro&, BF: Line (dw - 287, dh - 223)-(dw - 227, dh - 193), bl&, BF
_PutImage (dw * .5 - 100, 59), br&: _PutImage (dw * .5 - 100, dh - 109), br&: _PutImage (59, dh * .5 - 100), bru&: _PutImage (dw - 109, dh * .5 - 100), bru&
Line (dw * .5 - 200, dh * .5 - 100)-(dw * .5 + 200, dh * .5 + 100), gre&, BF: Line (dw * .5 - 180, dh * .5 - 80)-(dw * .5 + 180, dh * .5 + 80), bl&, BF
Line (dw * .5 - 80, dh * .5 - 100)-(dw * .5 + 80, dh * .5 + 100), bl&, BF: Line (dw * .5 - 200, dh * .5 - 30)-(dw * .5 + 200, dh * .5 + 30), bl&, BF
ctx = dw * .5: cty = dh * .5: Circle (ctx, cty), 30, t3&: Paint (ctx, cty), t3&, t3&: Circle (ctx, cty), 15, bl&: Circle (ctx, cty), 14, bl&: Circle (ctx, cty), 16, bl&
Line (ctx - 1, cty - 40)-(ctx + 1, cty + 40), t31&, BF: Line (ctx - 40, cty - 1)-(ctx + 40, cty + 1), t31&, BF: Circle (ctx, cty), 6, wh&: Paint (ctx, cty), bl&, wh&
f& = _LoadFont("data/font2.ttf", 16): _Font f&
Color bl&, bor&: a$ = "Press +/- for Speed / 1 or 2 for Tank AI / I for Info Screen / F to toggle Fullscreen": w1 = _PrintWidth(a$) * .5: Locate 48, dw * .5 - w1: Print a$;
Screen _NewImage(dw, dh, 32): dc = _Devices: _CapsLock Off

f& = _LoadFont("data/font2.ttf", 16): _Font f&: _PutImage , pls&
dio = 1: cloc = dw * .5 - 100: loc1 = dw * .5 - 198: loc2 = dw * .5 + 8: step1 = 1: x = 100: y = 100: a = dw - 101: b = dh - 101

Circle (x, y), 6, t1&: Paint (x, y), t1&, t1&: Circle (x, y), 3, bl&: Line (x, y)-(x + 12, y), red&
Circle (a, b), 6, t2&: Paint (a, b), t2&, t2&: Circle (a, b), 3, bl&: Line (a, b)-(a - 12, b), red&
Line (dw * .5 - 210, dh * .5 - 110)-(dw * .5 + 210, dh * .5 + 110), bor&, BF
Line (dw * .5 - 200, dh * .5 - 100)-(dw * .5 + 200, dh * .5 + 100), t2&, BF
Color bl&, t2&
PrintScreen "Thanks for playing Tank Battle By David Coterel", -5
PrintScreen "Tanks can be controlled with the keyboard or", -4
PrintScreen "Controllers, the Keyboard uses A,S,D,W and Space", -3
PrintScreen "for the Yellow Tank and the Cursor Keys and", -2
PrintScreen "Right CNTRL for the Green Tank, Tanks can fire", -1
PrintScreen "two bullets at a time, bullets will reflect if", 0
PrintScreen "they hit a brown wall and can be recaptured", 1
PrintScreen "by the tank that fired them but are deadly to", 2
PrintScreen "the other tank. 10 Kills wins the game.", 3
PrintScreen "If the center tank hits you you will loose 1 kill", 4
PrintScreen "I>Info F>Fullscreen 1-2 for AI Tank & ESC>Ends", 5
Do: _Limit 120: Locate dh / 32 + 6, cloc: Print " PRESS ENTER TO START ";: cloc = cloc + step1
    If cloc = loc2 Then step1 = -1: Sound 100, .5: Else If cloc = loc1 Then step1 = 1: Sound 100, .5
    _Display: i$ = InKey$: If i$ = "f" Then If _FullScreen = 0 Then _FullScreen Else _FullScreen _Off
Loop Until _KeyDown(13) Or _KeyDown(27): If _KeyDown(27) GoTo Gameover
_SndVol las&, .3

Start:

a2 = -1: b2 = 0: x2 = 1: y2 = 0: f1 = 0: f2 = 0: f3 = 0: f4 = 0: x = 100: y = 100
a = dw - 101: b = dh - 101: fx1 = 0: fy1 = 0: fa1 = 0: fb1 = 0


Do
    _Limit fps!: _PutImage , pls&
    d = 12 - (((Abs(x2) + Abs(y2)) - 1) * 4): Circle (x, y), 6, t1&: Paint (x, y), t1&, t1&: Circle (x, y), 3, bl&: Line (x, y)-(x + x2 * d, y + y2 * d), red&
    d = 12 - (((Abs(a2) + Abs(b2)) - 1) * 4): Circle (a, b), 6, t2&: Paint (a, b), t2&, t2&: Circle (a, b), 3, bl&: Line (a, b)-(a + a2 * d, b + b2 * d), red&
    If dt$ <> Time$ Then dt = 1 - dt: dt$ = Time$: If dt = 1 Then las = 0
    If dt = 1 Then Paint (ctx, cty), gre&, wh&
    If las = 0 Then _SndPlay las&: las = 1


    If ply1 <> -1 Then x1 = 0: y1 = 0
    If ply2 <> -1 Then a1 = 0: b1 = 0

    If f5 = 0 And dt = 1 Then
        For t = 43 To (dw * .5) - 16 Step 3
            PSet (ctx + t, cty - 1), gra&: PSet (ctx - t, cty - 1), gra&
            If (ply1 = 0 And Point(ctx + t, cty) = t1&) Or (ply2 = 0 And Point(ctx + t, cty) = t2&) Then ctx1 = 1: cty1 = 0: fire3 = 1
            If (ply1 = 0 And Point(ctx - t, cty) = t1&) Or (ply2 = 0 And Point(ctx - t, cty) = t2&) Then ctx1 = -1: cty1 = 0: fire3 = 1
        Next t

        For t = 43 To (dh * .5) - 16 Step 3
            PSet (ctx - 1, cty + t), gra&: PSet (ctx - 1, cty - t), gra&
            If (ply1 = 0 And Point(ctx, cty + t) = t1&) Or (ply2 = 0 And Point(ctx, cty + t) = t2&) Then ctx1 = 0: cty1 = 1: fire3 = 1
            If (ply1 = 0 And Point(ctx, cty - t) = t1&) Or (ply2 = 0 And Point(ctx, cty - t) = t2&) Then ctx1 = 0: cty1 = -1: fire3 = 1
        Next t
    End If


    If inf = -1 Then
        Color bl&, bor&: a$ = Str$(Int(_Hypot(x - a, y - b))): a$ = "Distance: " + Right$(a$, Len(a$) - 1): Locate 1, dw * .25 - 70: Print a$;
        Locate 1, dw * .75 - 60: Print Using "### ###"; x, y;: Locate 1, dw * .75 + 10: Print Using "### ###"; a, b;
        Locate 1, 16: Print "FPS:"; cfps: fps = fps + 1
        If t$ <> Time$ Then t$ = Time$: cfps = fps: fps = 0
        a$ = "Shots:" + Str$(sh): w1 = _PrintWidth(a$) + 16: Locate 1, dw - w1: Print a$;
    End If

    If f1 = 0 Then f1travel = 0
    If f2 = 0 Then f2travel = 0
    If f3 = 0 Then f3travel = 0
    If f4 = 0 Then f4travel = 0

    If f1 = 1 Then
        Circle (fx, fy), 2, mi&: Circle (fx + fx1, fy + fy1), 2, mi&: Circle (fx + fx1 * 2, fy + fy1 * 2), 2, mi&
        fx = fx + fx1 * 3: fy = fy + fy1 * 3: f1travel = f1travel + 1
        If f1travel = 200 Then f1 = 0
    End If

    If f2 = 1 Then
        Circle (fa, fb), 2, mi&: Circle (fa + fa1, fb + fb1), 2, mi&: Circle (fa + fa1 * 2, fb + fb1 * 2), 2, mi&
        fa = fa + fa1 * 3: fb = fb + fb1 * 3: f2travel = f2travel + 1
        If f2travel = 200 Then f2 = 0
    End If

    If f3 = 1 Then
        Circle (fc, fd), 2, mi&: Circle (fc + fc1, fd + fd1), 2, mi&: Circle (fc + fc1 * 2, fd + fd1 * 2), 2, mi&
        fc = fc + fc1 * 3: fd = fd + fd1 * 3: f3travel = f3travel + 1
        If f3travel = 200 Then f3 = 0
    End If

    If f4 = 1 Then
        Circle (fe, ff), 2, mi&: Circle (fe + fe1, ff + ff1), 2, mi&: Circle (fe + fe1 * 2, ff + ff1 * 2), 2, mi&
        fe = fe + fe1 * 3: ff = ff + ff1 * 3: f4travel = f4travel + 1
        If f4travel = 200 Then f4 = 0
    End If

    If f5 = 1 Then
        Circle (ctfx, ctfy), 2, mi&: Circle (ctfx + ctx1 * 2, ctfy + cty1 * 2), 2, mi&: Circle (ctfx + ctx1 * 4, ctfy + cty1 * 4), 2, mi&
        Circle (ctfx + ctx1 * 6, ctfy + cty1 * 6), 2, mi&: Circle (ctfx + ctx1 * 8, ctfy + cty1 * 8), 2, mi&
        ctfx = ctfx + ctx1 * 10: ctfy = ctfy + cty1 * 10
    End If

    If ply1 <> -1 Then
        If dc > 3 Then While _DeviceInput(4): Wend: x1 = _Axis(1): y1 = _Axis(2): fire1 = _Button(2)
        If x1 < -.5 Then x1 = -1 Else If x1 > .5 Then x1 = 1 Else x1 = 0
        If y1 < -.5 Then y1 = -1 Else If y1 > .5 Then y1 = 1 Else y1 = 0
        If _KeyDown(100) Then x1 = 1 Else If _KeyDown(97) Then x1 = -1
        If _KeyDown(115) Then y1 = 1 Else If _KeyDown(119) Then y1 = -1
    End If

    If ply2 <> -1 Then
        If dc > 2 Then While _DeviceInput(3): Wend: a1 = _Axis(1): b1 = _Axis(2): fire2 = _Button(2)
        If a1 < -.5 Then a1 = -1 Else If a1 > .5 Then a1 = 1 Else a1 = 0
        If b1 < -.5 Then b1 = -1 Else If b1 > .5 Then b1 = 1 Else b1 = 0
        If _KeyDown(19200) Then a1 = -1 Else If _KeyDown(19712) Then a1 = 1
        If _KeyDown(18432) Then b1 = -1 Else If _KeyDown(20480) Then b1 = 1
    End If


    If ply1 <> -1 And _KeyDown(32) And f1$ <> Time$ Then: fire1 = 1: f1$ = Time$
    If ply2 <> -1 And _KeyDown(100305) And f2$ <> Time$ Then fire2 = 1: f2$ = Time$





    If ply1 = -1 Then
        'AI1 Tank Moves
        If fu1$ <> Time$ And ob1$ <> Time$ Then
            x1 = 0: y1 = 0
            If _Hypot(x - a, y - b) > 40 Then
                If x < a - 3 Then x1 = 1 Else If x > a + 3 Then x1 = -1
                If y < b - 3 Then y1 = 1 Else If y > b + 3 Then y1 = -1
            End If
        End If

        'AI1 Tank encounters an obstacle
        colo = Point(x + x1 * 13, y + y1 * 13)
        If colo <> bl& And colo <> mi& And colo <> gra& And ob1$ <> Time$ Then
            ob1$ = Time$: px1 = x1: py1 = y1
            Recalc1: x1 = 1 - Int(Rnd(1) * 3): y1 = 1 - Int(Rnd(1) * 3)
            If Point(x + x1 * 20, y + y1 * 20) <> bl& GoTo Recalc1
            If px1 = x1 And py1 = y1 GoTo Recalc1
        End If

        'AI1 Tank fires
        t = 12: Do: t = t + 1: colo = Point(x + x2 * t, y + y2 * t): Loop Until (colo <> bl& And colo <> gra&) Or t > 300
        If (colo = t2& Or colo = red&) And ftime1$ <> Time$ Then fire1 = 1: ftime1$ = Time$

        'AI1 Tank is fired upon (retreats)
        If (f2 = 1 Or f4 = 1) And fu1$ <> Time$ And (_Hypot(x - fa, y - fb) < 200 Or _Hypot(x - fe, y - ff) < 200) Then
            px1 = x1: py1 = y1: fu1$ = Time$
            Recalc2: x1 = 1 - Int(Rnd(1) * 3): y1 = 1 - Int(Rnd(1) * 3)
            If Point(x + x1 * 20, y + y1 * 20) <> bl& GoTo Recalc2
            If x1 = px1 And y1 = py1 GoTo Recalc2
            If x1 = px1 * -1 And y1 = py1 * -1 GoTo Recalc2
        End If
    End If


    If ply2 = -1 Then
        'AI2 Tank Moves
        If fu2$ <> Time$ And ob2$ <> Time$ Then
            a1 = 0: b1 = 0
            If _Hypot(a - x, b - y) > 40 Then
                If a < x - 3 Then a1 = 1 Else If a > x + 3 Then a1 = -1
                If b < y - 3 Then b1 = 1 Else If b > y + 3 Then b1 = -1
            End If
        End If

        'AI2 Tank encounters an obstacle
        colo = Point(a + a1 * 13, b + b1 * 13)
        If colo <> bl& And colo <> mi& And colo <> gra& And ob2$ <> Time$ Then
            ob2$ = Time$: pa1 = a1: pb1 = b1
            Recalc3: a1 = 1 - Int(Rnd(1) * 3): b1 = 1 - Int(Rnd(1) * 3)
            If Point(a + a1 * 20, b + b1 * 20) <> bl& GoTo Recalc3
            If pa1 = a1 And pb1 = b1 GoTo Recalc3
        End If

        'AI2 Tank fires
        t = 12: Do: t = t + 1: colo = Point(a + a2 * t, b + b2 * t): Loop Until (colo <> bl& And colo <> gra&) Or t > 300
        If (colo = t1& Or colo = red&) And ftime2$ <> Time$ Then fire2 = 1: ftime2$ = Time$

        'AI2 Tank is fired upon (retreats)
        If (f1 = 1 Or f3 = 1) And fu2$ <> Time$ And (_Hypot(a - fc, b - fd) < 200 Or _Hypot(a - fx, b - fy) < 200) Then
            pa1 = a1: pb1 = b1: fu2$ = Time$
            Recalc4: a1 = 1 - Int(Rnd(1) * 3): b1 = 1 - Int(Rnd(1) * 3)
            If Point(a + a1 * 20, b + b1 * 20) <> bl& GoTo Recalc4
            If a1 = pa1 And b1 = pb1 GoTo Recalc4
            If a1 = pa1 * -1 And b1 = pb1 * -1 GoTo Recalc4
        End If
    End If





    If x1 <> 0 Or y1 <> 0 Then x2 = x1: y2 = y1
    If a1 <> 0 Or b1 <> 0 Then a2 = a1: b2 = b1

    If fire1 <> 0 Then GoSub fire1 Else ss1 = 0
    If fire2 <> 0 Then GoSub fire2 Else ss2 = 0
    If fire3 <> 0 Then GoSub fire3

    If Point(x + x1 * 13, y + y1 * 13) <> bl& And Point(x + x1 * 13, y + y1 * 13) <> gra& Then x1 = 0: y1 = 0
    If Point(a + a1 * 13, b + b1 * 13) <> bl& And Point(a + a1 * 13, b + b1 * 13) <> gra& Then a1 = 0: b1 = 0

    x = x + x1: y = y + y1: a = a + a1: b = b + b1

    If x1 <> 0 Or y1 <> 0 Then _SndLoop tm1& Else _SndStop tm1&
    If a1 <> 0 Or b1 <> 0 Then _SndLoop tm2& Else _SndStop tm2&

    If f1 = 1 And _Hypot(a - fx, b - fy) < 10 Then s1 = s1 + 1: f1 = 0: thit = 2: GoTo tahit
    If f2 = 1 And _Hypot(x - fa, y - fb) < 10 Then s2 = s2 + 1: f2 = 0: thit = 1: GoTo tahit
    If f3 = 1 And _Hypot(a - fc, b - fd) < 10 Then s1 = s1 + 1: f3 = 0: thit = 2: GoTo tahit
    If f4 = 1 And _Hypot(x - fe, y - ff) < 10 Then s2 = s2 + 1: f4 = 0: thit = 1: GoTo tahit
    If f5 = 1 And ply1 = 0 And _Hypot(ctfx - x, ctfy - y) < 10 Then f5 = 0: s1 = s1 - 1: thit = 1: GoTo tahit
    If f5 = 1 And ply2 = 0 And _Hypot(ctfx - a, ctfy - b) < 10 Then f5 = 0: s2 = s2 - 1: thit = 2: GoTo tahit

    If f1 = 1 And Point(fx + fx1 * 3, fy + fy1 * 3) = bro& Then p1 = 1: Reflect fx, fy, fx1, fy1: Else p1 = 0
    If f2 = 1 And Point(fa + fa1 * 3, fb + fb1 * 3) = bro& Then p2 = 1: Reflect fa, fb, fa1, fb1: Else p2 = 0
    If f3 = 1 And Point(fc + fc1 * 3, fd + fd1 * 3) = bro& Then p3 = 1: Reflect fc, fd, fc1, fd1: Else p3 = 0
    If f4 = 1 And Point(fe + fe1 * 3, ff + ff1 * 3) = bro& Then p4 = 1: Reflect fe, ff, fe1, ff1: Else p4 = 0

    If f1 = 1 And Point(fx + fx1 * 2, fy + fy1 * 2) <> bl& And Point(fx + fx1 * 2, fy + fy1 * 2) <> red& And Point(fx + fx1 * 2, fy + fy1 * 2) <> gra& Then f1 = 0
    If f2 = 1 And Point(fa + fa1 * 2, fb + fb1 * 2) <> bl& And Point(fa + fa1 * 2, fb + fb1 * 2) <> red& And Point(fa + fa1 * 2, fb + fb1 * 2) <> gra& Then f2 = 0
    If f3 = 1 And Point(fc + fc1 * 2, fd + fd1 * 2) <> bl& And Point(fc + fc1 * 2, fd + fd1 * 2) <> red& And Point(fc + fc1 * 2, fd + fd1 * 2) <> gra& Then f3 = 0
    If f4 = 1 And Point(fe + fe1 * 2, ff + ff1 * 2) <> bl& And Point(fe + fe1 * 2, ff + ff1 * 2) <> red& And Point(fe + fe1 * 2, ff + ff1 * 2) <> gra& Then f4 = 0
    If f5 = 1 And Point(ctfx + ctx1 * 2, ctfy + cty1 * 2) = bor& Then f5 = 0



    Color bl&, bor&: a$ = "Yellow ###  -  Green ###": w1 = _PrintWidth(a$) * .5: Locate 1, dw * .5 - w1
    Print Using a$; s1; s2;: Color bl&, bl&: _Display
    i$ = InKey$: If i$ = "i" Then inf = Not (inf)
    If i$ = "1" Then ply1 = Not (ply1)
    If i$ = "2" Then ply2 = Not (ply2)
    If i$ = "f" Then If _FullScreen = 0 Then _FullScreen Else _FullScreen _Off
    If i$ = "+" Then fps! = fps! + 5: If fps! = 125 Then fps! = 120
    If i$ = "-" Then fps! = fps! - 5: If fps! = 15 Then fps! = 20
Loop Until _KeyDown(27): GoTo Gameover


tahit:
_SndStop tm1&: _SndStop tm2&: Color bl&, bor&: a$ = "Yellow ###  -  Green ###": w1 = _PrintWidth(a$) * .5
Locate 1, dw * .5 - w1: Print Using a$; s1; s2;: If thit = 2 Then x = a: y = b
_SndPlay ex&: For a = 1 To 3: For b = 1 To 17: _Limit 20
        Circle (x, y), b, wh&: Circle (x, y), b - 1, bl&
_Display: Next b, a
If ply1 = -1 And ply2 = -1 GoTo Start
If s1 < 10 And s2 < 10 GoTo Start


Gameover:
_SndStop tm1&: _SndStop tm2&: Do While _KeyDown(27): _Limit 60: Loop
Line (dw * .5 - 210, dh * .5 - 110)-(dw * .5 + 210, dh * .5 + 110), bor&, BF
Line (dw * .5 - 200, dh * .5 - 100)-(dw * .5 + 200, dh * .5 + 100), t2&, BF
Color bl&, t2&
PrintScreen "Thanks for playing Tank Battle By David Coterel", -2
If s1 > s2 Then PrintScreen "Player 1 (Yellow) is the Winner", 0
If s2 > s1 Then PrintScreen "Player 2 (Green) Wins the game", 0
If s2 = s1 Then PrintScreen "Player 1 ->  Tie Game  <- Player 2", 0
PrintScreen "Press ESC to end", 2: _Display
Do: _Limit 60: Loop Until _KeyDown(27)
_FreeImage pls&: _Font 16: _FreeFont f&: _AutoDisplay: System


fire1:
fire1 = 0
If f1 = 0 And (x2 <> 0 Or y2 <> 0) And Point(x + x2 * 18, y + y2 * 18) = bl& Then
    f1 = 1: sh = sh + 1: fx1 = x2: fy1 = y2: fx = x + fx1 * 13: fy = y + fy1 * 13: _SndPlay fir&: ss1 = 1
End If

If ss1 = 0 And f1 = 1 And f3 = 0 And (x2 <> 0 Or y2 <> 0) And Point(x + x2 * 18, y + y2 * 18) = bl& Then
    f3 = 1: sh = sh + 1: fc1 = x2: fd1 = y2: fc = x + fc1 * 13: fd = y + fd1 * 13: _SndPlay fir&
End If
Return


fire2:
fire2 = 0
If f2 = 0 And (a2 <> 0 Or b2 <> 0) And Point(a + a2 * 18, b + b2 * 18) = bl& Then
    f2 = 1: sh = sh + 1: fa1 = a2: fb1 = b2: fa = a + fa1 * 14: fb = b + fb1 * 14: _SndPlay fir&: ss2 = 1
End If

If ss2 = 0 And f2 = 1 And f4 = 0 And (a2 <> 0 Or b2 <> 0) And Point(a + a2 * 18, b + b2 * 18) = bl& Then
    f4 = 1: sh = sh + 1: fe1 = a2: ff1 = b2: fe = a + fe1 * 13: ff = b + ff1 * 13: _SndPlay fir&
End If
Return


fire3:
fire3 = 0: sh = sh + 1: f5 = 1:: ctfx = ctx + ctx1 * 40: ctfy = cty + cty1 * 40: _SndPlay fir&
Return


Sub Reflect (a, b, e, f)
    If Point(a, b + 3) = bro& Or Point(a, b - 3) = bro& Then f = f * -1
    If Point(a + 3, b) = bro& Or Point(a - 3, b) = bro& Then e = e * -1
End Sub


Sub PrintScreen (a$, voff)
    w1 = _PrintWidth(a$) * .5: Locate dh / 32 + voff, dw * .5 - w1: Print a$: _Display
End Sub


Attached Files
.zip   Tank.zip (Size: 4.03 MB / Downloads: 52)
Reply


Messages In This Thread
Tank Battle - One or Two Player - by dcoterel - 09-01-2025, 01:07 AM
RE: Tank Battle - Two Player - by madscijr - 09-02-2025, 01:35 AM
RE: Tank Battle - Two Player - by dcoterel - 09-02-2025, 08:50 PM
RE: Tank Battle - Two Player - by madscijr - 09-02-2025, 10:25 PM
RE: Tank Battle - Two Player - by madscijr - 09-03-2025, 01:53 PM
RE: Tank Battle - Two Player - by Unseen Machine - 09-02-2025, 08:51 PM
RE: Tank Battle - Two Player - by Unseen Machine - 09-02-2025, 11:22 PM
RE: Tank Battle - Two Player - by madscijr - 09-03-2025, 01:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mouse Tank SierraKen 31 4,511 01-30-2025, 08:11 PM
Last Post: SierraKen

Forum Jump:


Users browsing this thread: 1 Guest(s)