%This game made by the Martin Lindsay November 2004.
%Do not illegally alter this game in any way, or i will yell at you angrily.
setscreen ( "graphics:500;500, nobuttonbar" )
var chars : array char of boolean
var x, y, x2, y2, a, b, a2, b2, blue_wins, red_wins : int := 0
var ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8, ch9 : int
var attacker, word : string
var sidecheckred, timer, sidecheckblue, randomattack : int
%instructions for playing, and enterting of names
var player_red, player_blue : string
put "Enter the name of the red player... " ..
get player_red
put "Red player will use the arrow keys to move."
put "Enter the name of the blue player... " ..
get player_blue
put "Blue player will use w, s, a and d to move."
put "What ever colour is at the top is the attacking colour."
delay (5000)
loop
%makes the attacker random
randomattack:= Rand.Int (1, 2)
%sets all the variables for the beginning of the round
a := 490
b := 0
x := 1
a2 := a + 10
b2 := b + 10
y := 1
x2 := x + 10
y2 := y + 10
timer := 0
put "Get ready..."
delay (3000)
cls
%shows users who the attacker is
if randomattack=1 then
attacker := "red"
drawfillbox (0, 401, 500, 500, red)
elsif randomattack=2 then
attacker := "blue"
drawfillbox (0, 401, 500, 500, blue)
timer:=6001
end if
%main body loop
loop
%erases the boxes
drawfillbox (a, b, a2, b2, white)
drawfillbox (x, y, x2, y2, white)
%loop count increases
timer := timer + 1
%player controls
Input.KeyDown (chars)
locate (1, 1)
if chars (KEY_UP_ARROW) then
y := y + 1
end if
if chars (KEY_RIGHT_ARROW) then
x := x + 1
end if
if chars (KEY_LEFT_ARROW) then
x := x - 1
end if
if chars (KEY_DOWN_ARROW) then
y := y - 1
end if
if chars ('w') then
b := b + 1
end if
if chars ('s') then
b := b - 1
end if
if chars ('a') then
a := a - 1
end if
if chars ('d') then
a := a + 1
end if
%figures out the rest of the variables for drawing the squares
a2 := a + 10
b2 := b + 10
x2 := x + 10
y2 := y + 10
%keeps the squares in the screen
if x=491 then
x:=x-1
end if
if x=-1 then
x :=x+1
end if
if y=-1 then
y:=y+1
end if
if y=391 then
y:=y - 1
end if
if a=491 then
a:=a - 1
end if
if a=-1 then
a :=a +1
end if
if b=-1 then
b:=b + 1
end if
if b=391 then
b:=b - 1
end if
%calculates the coordinates of the suares again
x2 := x + 10
y2 := y + 10
a2 := a + 10
b2 := b + 10
%draws the squares
drawfillbox (a, b, a2, b2, blue)
drawfillbox (x, y, x2, y2, red)
delay (2)
%prepares for overlapping check
ch1 := y + 1
ch2 := y + 2
ch3 := y + 3
ch4 := y + 4
ch5 := y + 5
ch6 := y + 6
ch7 := y + 7
ch8 := y + 8
ch9 := y + 9
%the following area of the code checks if the squares overlap
%now i know i could do this much faster with arrays and for blocks...
%but i originally made this game 3 weeks after i started programming, so ill spruce it up later
if attacker="red" or attacker="blue" then
if x=a then
if y=b then
exit
elsif y=b2 then
exit
elsif y2=b then
exit
elsif y2=b2 then
exit
elsif ch1=b then
exit
elsif ch1=b2 then
exit
elsif ch2=b then
exit
elsif ch2=b2 then
exit
elsif ch3=b then
exit
elsif ch3=b2 then
exit
elsif ch4=b then
exit
elsif ch4=b2 then
exit
elsif ch5=b then
exit
elsif ch5=b2 then
exit
elsif ch6=b then
exit
elsif ch6=b2 then
exit
elsif ch7=b then
exit
elsif ch7=b2 then
exit
elsif ch8=b then
exit
elsif ch8=b2 then
exit
elsif ch9=b then
exit
elsif ch9=b2 then
exit
end if
elsif x=a2 then
if y=b then
exit
elsif y=b2 then
exit
elsif y2=b then
exit
elsif y2=b2 then
exit
elsif ch1=b then
exit
elsif ch1=b2 then
exit
elsif ch2=b then
exit
elsif ch2=b2 then
exit
elsif ch3=b then
exit
elsif ch3=b2 then
exit
elsif ch4=b then
exit
elsif ch4=b2 then
exit
elsif ch5=b then
exit
elsif ch5=b2 then
exit
elsif ch6=b then
exit
elsif ch6=b2 then
exit
elsif ch7=b then
exit
elsif ch7=b2 then
exit
elsif ch8=b then
exit
elsif ch8=b2 then
exit
elsif ch9=b then
exit
elsif ch9=b2 then
end if
elsif x2=a then
if y=b then
exit
elsif y=b2 then
exit
elsif y2=b then
exit
elsif y2=b2 then
exit
end if
elsif x2=a2 then
if y=b then
exit
elsif y=b2 then
exit
elsif y2=b then
exit
elsif y2=b2 then
exit
end if
end if
end if
%checks for attaqck change
if timer=6000 then
attacker :="blue"
drawfillbox (0, 401, 500, 500, blue)
elsif timer=5000 then
attacker := "none"
drawfillbox (0, 401, 500, 500, white)
locate (3, 10)
put "Attacker is Changing..."
elsif timer=11000 then
attacker:="none"
drawfillbox (0, 401, 500, 500, white)
locate (3, 10)
put "Attacker is Changing..."
elsif timer=12000 then
attacker:="red"
drawfillbox (0, 401, 500, 500, red)
timer := 0
end if
end loop
%outputs scores.
if attacker="red"
then cls
put player_red ," Wins."
red_wins :=red_wins + 1
elsif attacker="blue" then
cls
put player_blue ," Wins."
blue_wins := blue_wins + 1
end if
put player_red ,"-", red_wins ," ", player_blue ,"-", blue_wins
put "Play again? (y)es or (n)o."
loop
Input.KeyDown (chars)
if chars ('y') or chars ('Y') then
word:="y"
exit
elsif chars ('n') or chars ('N') then
word:="n"
exit
end if
end loop
if word="y" then
put "Yes."
else
exit
end if
end loop
cls
put "Thank you for playing."
|