
-----------------------------------
petree08
Wed Oct 25, 2006 9:27 am

Tank fighting two player game
-----------------------------------
This game was made  a year ago when I first started making games. It is kind of long and has some bad code in it but it is a fun game.

Controls :

Player1 : 
movement : arrow keys 
shoot : enter

Player 2
movement : the a,  s, d, w kets
shoot : space bar




setscreen ("graphics:max,max,nobuttonbar,offscreenonly")
cls
var Xex, Yex : int
var YesNo : string (2)
var Font1 : int := Font.New ("Arial:50")
var Font2 : int := Font.New ("Arial:20")
var Count1, Count2 : nat := 0
var X1, Y1, X2, Y2 : int
var Health1, Health2 : int := 0
var XS1, XS2, YS1, YS2 : int
var Hit1, Hit2, Bang, Bang2 : boolean := false
var Right2, Left2, Up2, Down2 : boolean := false
var Right1, Left1, Up1, Down1 : boolean := false
var Key : array char of boolean

var Ch : char
procedure Pause

    Ch := getchar
end Pause



% sound
process Beep
    sound (200, 100)
end Beep

% shooting
process Shot2
    Hit2 := true
    XS2 := X2
    YS2 := Y2

    if Up2 = true then
        loop
            Count2 += 1
            YS2 := YS2 + 1

            exit when Count2 >= 3000
        end loop

    elsif Down2 = true then
        loop
            Count2 += 1
            YS2 := YS2 - 1

            exit when Count2 >= 3000
        end loop

    elsif Right2 = true then
        loop
            Count2 += 1
            XS2 := XS2 + 1

            exit when Count2 >= 3000
        end loop

    elsif Left2 = true then
        loop
            Count2 += 1
            XS2 := XS2 - 1


            exit when Count2 >= 3000
        end loop

    end if
    Count2 := 0
    Bang2 := false
    Hit2 := false
end Shot2

process Shot1
    Hit1 := true
    XS1 := X1

    YS1 := Y1
    if Up1 = true then
        loop
            Count1 += 1
            YS1 := YS1 + 1

            exit when Count1 >= 3000
        end loop

    elsif Down1 = true then
        loop
            Count1 += 1
            YS1 := YS1 - 1

            exit when Count1 >= 3000
        end loop

    elsif Right1 = true then
        loop
            Count1 += 1
            XS1 := XS1 + 1

            exit when Count1 >= 3000
        end loop

    elsif Left1 = true then
        loop
            Count1 += 1
            XS1 := XS1 - 1

            exit when Count1 >= 3000
        end loop

    end if
    Count1 := 0
    Hit1 := false
    Bang := false
end Shot1



const Midx := maxx div 2
const Midy := maxy div 2
colorback (7)
loop



    cls
    Font.Draw ("TANK-FIGHTERZ", 50, Midy, Font1, 10)
    Font.Draw ("press any key to continue", 50, Midy - 100, Font2, 12)
    Font.Draw ("made by Peter Watt", 50, Midy - 200, Font2, 0)
    View.Update
    Pause


    Health1 := 0
    Health2 := 0
    X1 := 10
    Y1 := Midy + 100

    X2 := maxx - 10
    Y2 := Midy - 100

    Left1 := true
    Right2 := true
    cls
    color (0)

    put " the object of this game is to destroy your apponent "
    put ""
    put ""
    color (12)
    put "Player1 controls "
    put ""
    put "Up    : Up arrow "
    put "Down  : Down arrow"
    put "Left  : Left Arrow"
    put "Right : Right Arrow"
    put "Shoot : Enter Key"
    put ""
    put ""
    color (10)
    put "Player 2 controls"
    put "Up    : w key "
    put "Down  : s key"
    put "Left  : a key"
    put "Right :  d key"
    put "Shoot : Space bar"
    color (0)
    put "press any key to continue"
    View.Update
    Pause


    loop
         cls

        %player boundries
        if X1 >= maxx then
            X1 := X1 - 1
        elsif X1 = maxy then
            Y1 := Y1 - 1
        elsif Y1 = maxx then
            X2 := X2 - 1
        elsif X2 = maxy then
            Y2 := Y2 - 1
        elsif Y2  Y2 - 20 and YS1 < Y2 + 20 and XS1 > X2 - 20 and XS1 < X2 + 20 then
            Health1 += 5
            fork Beep
            Bang := true

        end if
        if Hit2 = true and Bang2 = false and YS2 > Y1 - 20 and YS2 < Y1 + 20 and XS2 > X1 - 20 and XS2 < X1 + 20 then
            Health2 += 5
            fork Beep
            Bang2 := true

        end if
        color (10)
        put "Green tanks damage: ", Health1, " %" : 10 ..
        color (12)
      
          put "Red tanks damage: ", Health2, " %"
        exit when Health1 >= 100 or Health2 >= 100
        View.Update
    end loop

    if X1 > X2 - 50 and X1 = 100 then
            drawfilloval (XS2, YS2, 2, 2, 7)




          
            Font.Draw ("The green tank wins!", 1, Midy, Font1, 10)
        elsif Health1 >= 100 then
          
            Font.Draw ("The red tank wins!", 1, Midy, Font1, 12)

        end if
    end if
    put " Would you like to play again? (y/n?"
    View.Update
    get YesNo
    exit when YesNo = "n"
end loop




-----------------------------------
Silent Avenger
Wed Oct 25, 2006 3:00 pm


-----------------------------------
I have to say "that's a fun game when you have nothing else to do". A friend and I were playing it today in our compsci class. Good job on this.
