
-----------------------------------
petree08
Fri Sep 22, 2006 11:11 am

sweet tank game
-----------------------------------
setscreen ("graphics:max,max,nobuttonbar,offscreenonly")
cls
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





% shooting procedures
process Shot2
    Hit2 := true
    XS2 := X2
    YS2 := Y2
    if Up2 = true then
        loop
            Count2 += 1
            YS2 := YS2 + 1
            delay (0)
            exit when Count2 >= 1000
        end loop

    elsif Down2 = true then
        loop
            Count2 += 1
            YS2 := YS2 - 1
            delay (0)
            exit when Count2 >= 1000
        end loop

    elsif Right2 = true then
        loop
            Count2 += 1
            XS2 := XS2 + 1
            delay (0)
            exit when Count2 >= 1000
        end loop

    elsif Left2 = true then
        loop
            Count2 += 1
            XS2 := XS2 - 1
            delay (0)
            exit when Count2 >= 1000
        end loop

    end if
    Count2 := 0
    Hit2 := false
end Shot2

process Shot1
    Hit1 := true
    XS1 := X1
    YS1 := Y1
    if Up1 = true then
        loop
            Count1 += 1
             delay (0)
            YS1 := YS1 + 1
            exit when Count1 >= 1000
        end loop

    elsif Down1 = true then
        loop
            Count1 += 1
            YS1 := YS1 - 1
            delay (0) 
            exit when Count1 >= 1000
        end loop

    elsif Right1 = true then
        loop
            Count1 += 1
            delay (0)
            XS1 := XS1 + 1
            exit when Count1 >= 1000
        end loop

    elsif Left1 = true then
        loop
            Count1 += 1
            XS1 := XS1 - 1
            exit when Count1 >= 1000
        end loop

    end if
    Count1 := 0
    Hit1 := 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 - 2
        elsif X1 = maxy then
            Y1 := Y1 - 2
        elsif Y1 = maxx then
            X2 := X2 - 2
        elsif X2 = maxy then
            Y2 := Y2 - 2
        elsif Y2  Y2 - 20 and YS1 < Y2 + 20 and XS1 > X2 - 20 and XS1 < X2 + 20 then
            Health1 += 5

        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

        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
    cls

    if Health2 >= 100 then
        Font.Draw ("The green tank wins!", 1, Midy, Font1, 10)
    else
        Font.Draw ("The red tank wins!", 1, Midy, Font1, 12)
    end if
    put " Would you like to play again? (y/n?"
    View.Update
    get YesNo
    exit when YesNo = "n"
end loop

mod edit: added tags

-----------------------------------
viperfan7
Wed Nov 08, 2006 7:39 pm


-----------------------------------
ok heres a tip, put the source code in the middle of 2 code tags by first pressing the Code button next to the Quotes and type in the code, then press the Code button again, makes it easeir to understand, and sorry for necroposting[/code]

-----------------------------------
DemonZ
Thu Nov 09, 2006 3:31 pm


-----------------------------------
the tank game is alright, but there is a bug with not being able to exit the program, and you could have made a menu for user friendlyness, overall, the game is ok, but there is a problem with some of the controls are locking up. but other than that, a good game.

-----------------------------------
BenLi
Thu Nov 09, 2006 6:28 pm


-----------------------------------
well someone necro posted... so what the heck...


        Input.KeyDown (Key)
        if Key (KEY_DOWN_ARROW) then
            Down1 := true
            Up1 := false
            Right1 := false
            Left1 := false
            Y1 := Y1 - 2

        elsif Key (KEY_UP_ARROW) then
            Up1 := true
            Down1 := false
            Right1 := false
            Left1 := false
            Y1 := Y1 + 2


        elsif Key (KEY_LEFT_ARROW) then
            Up1 := false
            Down1 := false
            Right1 := false
            Left1 := true
            X1 := X1 - 2


        elsif Key (KEY_RIGHT_ARROW) then
            Up1 := false
            Down1 := false
            Right1 := true
            Left1 := false
            X1 := X1 + 2

        end if


a very small change of seperating the if structures would allow for diagonal movement


        Input.KeyDown (Key)
        if Key (KEY_DOWN_ARROW) then
            Down1 := true
            Up1 := false
            Right1 := false
            Left1 := false
            Y1 := Y1 - 2

        elsif Key (KEY_UP_ARROW) then
            Up1 := true
            Down1 := false
            Right1 := false
            Left1 := false
            Y1 := Y1 + 2
        end if

        if Key (KEY_LEFT_ARROW) then
            Up1 := false
            Down1 := false
            Right1 := false
            Left1 := true
            X1 := X1 - 2


        elsif Key (KEY_RIGHT_ARROW) then
            Up1 := false
            Down1 := false
            Right1 := true
            Left1 := false
            X1 := X1 + 2

        end if
[/quote]
