colour (brightgreen)
put "PLEASE ENTER THE NAMES OF THE TWO PLAYERS!"
get name1
get name2
var x1, y1, button, buttonnumber, buttonupdown : int
var counter : int := 1
var x : array 1 .. 8 of int
var o : array 1 .. 8 of int
var ch : string(1)
for loc : 1 .. 8
x (loc) := 0
o (loc) := 0
end for
setscreen ("graphics:400,400")
font := Font.New ("Palatino:38:bold")
Draw.FillBox (maxx, maxy, 0, 0, black)
Draw.FillBox (135, 0, 131, maxy, brightgreen)
Draw.FillBox (268, 0, 264, maxy, brightgreen)
Draw.FillBox (0, 135, maxx, 131, brightgreen)
Draw.FillBox (0, 268, maxx, 264, brightgreen)
procedure one
if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
Draw.Text ("X", 50, 320, font, brightgreen)
x (3) := x (3) + 1
x (4) := x (4) + 1
x (8) := x (8) + 1
else
Draw.Text ("O", 50, 320, font, brightgreen)
o (3) := o (3) + 1
o (4) := o (4) + 1
o (8) := o (8) + 1
end if
end one
procedure two
if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
Draw.Text ("X", 175, 320, font, brightgreen)
x (2) := x (2) + 1
x (4) := x (4) + 1
else
Draw.Text ("O", 175, 320, font, brightgreen)
o (2) := o (2) + 1
o (4) := o (4) + 1
end if
end two
procedure three
if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
Draw.Text ("X", 300, 320, font, brightgreen)
x (1) := x (1) + 1
x (4) := x (4) + 1
x (7) := x (7) + 1
else
Draw.Text ("O", 300, 320, font, brightgreen)
o (1) := o (1) + 1
o (4) := o (4) + 1
o (7) := o (7) + 1
end if
end three
procedure four
if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
Draw.Text ("X", 50, 175, font, brightgreen)
x (3) := x (3) + 1
x (5) := x (5) + 1
else
Draw.Text ("O", 50, 175, font, brightgreen)
o (3) := o (3) + 1
o (5) := o (5) + 1
end if
end four
procedure five
if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
Draw.Text ("X", 175, 175, font, brightgreen)
x (2) := x (2) + 1
x (5) := x (5) + 1
x (7) := x (7) + 1
x (8) := x (8) + 1
else
Draw.Text ("O", 175, 175, font, brightgreen)
o (2) := o (2) + 1
o (5) := o (5) + 1
o (7) := o (7) + 1
o (8) := o (8) + 1
end if
end five
procedure six
if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
Draw.Text ("X", 300, 175, font, brightgreen)
x (1) := x (1) + 1
x (5) := x (5) + 1
else
Draw.Text ("O", 300, 175, font, brightgreen)
o (1) := o (1) + 1
o (5) := o (5) + 1
end if
end six
procedure seven
if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
Draw.Text ("X", 50, 50, font, brightgreen)
x (3) := x (3) + 1
x (6) := x (6) + 1
x (7) := x (7) + 1
else
Draw.Text ("O", 50, 50, font, brightgreen)
o (3) := o (3) + 1
o (6) := o (6) + 1
o (7) := o (7) + 1
end if
end seven
procedure eight
if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
Draw.Text ("X", 175, 50, font, brightgreen)
x (2) := x (2) + 1
x (6) := x (6) + 1
else
Draw.Text ("O", 175, 50, font, brightgreen)
o (2) := o (2) + 1
o (6) := o (6) + 1
end if
end eight
procedure nine
if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
Draw.Text ("X", 300, 50, font, brightgreen)
x (1) := x (1) + 1
x (6) := x (6) + 1
x (8) := x (8) + 1
else
Draw.Text ("O", 300, 50, font, brightgreen)
o (1) := o (1) + 1
o (6) := o (6) + 1
o (8) := o (8) + 1
end if
end nine
loop
mousewhere (x1, y1, button)
if button = 1 and x1 >= 0 and x1 <= 133 and y1 >= 268 and win not= 1 then
one
elsif button = 1 and x1 >= 134 and x1 <= 268 and y1 >= 268 and win not= 1 then
two
elsif button = 1 and x1 >= 267 and x1 <= maxx and y1 >= 268 and win not= 1 then
three
elsif button = 1 and x1 >= 0 and x1 <= 133 and y1 <= 268 and y1 >= 135 and win not= 1 then
four
elsif button = 1 and x1 >= 134 and x1 <= 268 and y1 >= 135 and y1 <= 268 and win not= 1 then
five
elsif button = 1 and x1 >= 267 and x1 <= maxx and y1 >= 135 and y1 <= 268 and win not= 1 then
six
elsif button = 1 and x1 >= 0 and x1 <= 133 and y1 >= 0 and y1 <= 134 and win not= 1 then
seven
elsif button = 1 and x1 >= 134 and x1 <= 268 and y1 >= 0 and y1 <= 134 and win not= 1 then
eight
elsif button = 1 and x1 >= 268 and x1 <= maxx and y1 >= 0 and y1 <= 134 and win not= 1 then
nine
end if
if button = 1 then
counter := counter + 1
delay (500)
end if
exit when counter = 11
if x (1) = 3 or x (2) = 3 or x (3) = 3 or x (4) = 3 or x (5) = 3 or x (6) = 3 or x (7) = 3 or x (8) = 3 then
locate (25, 5)
put name1, " WINS!!"
win := 1
exit
elsif o (1) = 3 or o (2) = 3 or o (3) = 3 or o (4) = 3 or o (5) = 3 or o (6) = 3 or o (7) = 3 or o (8) = 3 then
locate (25, 5)
put name2, " WINS!!!"
win := 1
exit
elsif counter = 10 then
locate (25, 5)
put "TIE GAME!"
win := 1
exit
end if
end loop
|