setscreen ("graphics: 460;480")
var x, y, button : int
var count : int := 1
var reds : array 1 .. 8 of int
var blues : array 1 .. 8 of int
for i : 1 .. 8
reds (i) := 0
blues (i) := 0
end for
%blue1 top horizontal
%blue2 middle horizontal
%blue3 bottom horizontal
%blue4 left vertical
%blue5 middle vertical
%blue6 right vertical
%blue7 diagonal from top left
%blue8 diagonal form top right
%layout
drawbox (100, 100, 400, 400, black)
drawline (200, 100, 200, 400, black)
drawline (300, 100, 300, 400, black)
drawline (100, 200, 400, 200, black)
drawline (100, 300, 400, 300, black)
procedure one_and_one
if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
drawfilloval (150, 150, 50, 50, brightblue)
blues (3) := blues (3) + 1
blues (4) := blues (4) + 1
blues (8) := blues (8) + 1
elsif count = 2 or count = 4 or count = 6 or count = 8 then
drawfilloval (150, 150, 50, 50, brightred)
reds (3) := reds (3) + 1
reds (4) := reds (4) + 1
reds (8) := reds (8) + 1
end if
end one_and_one
procedure one_and_two
if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
drawfilloval (150, 250, 50, 50, brightblue)
blues (2) := blues (2) + 1
blues (4) := blues (4) + 1
elsif count = 2 or count = 4 or count = 6 or count = 8 then
drawfilloval (150, 250, 50, 50, brightred)
reds (2) := reds (2) + 1
reds (4) := reds (4) + 1
end if
end one_and_two
procedure one_and_three
if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
drawfilloval (150, 350, 50, 50, brightblue)
blues (1) := blues (1) + 1
blues (4) := blues (4) + 1
blues (7) := blues (7) + 1
elsif count = 2 or count = 4 or count = 6 or count = 8 then
drawfilloval (150, 350, 50, 50, brightred)
reds (1) := reds (1) + 1
reds (4) := reds (4) + 1
reds (7) := reds (7) + 1
end if
end one_and_three
procedure two_and_one
if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
drawfilloval (250, 150, 50, 50, brightblue)
blues (3) := blues (3) + 1
blues (5) := blues (5) + 1
elsif count = 2 or count = 4 or count = 6 or count = 8 then
drawfilloval (250, 150, 50, 50, brightred)
reds (3) := reds (3) + 1
reds (5) := reds (5) + 1
end if
end two_and_one
procedure two_and_two
if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
drawfilloval (250, 250, 50, 50, brightblue)
blues (2) := blues (2) + 1
blues (5) := blues (5) + 1
blues (7) := blues (7) + 1
blues (8) := blues (8) + 1
elsif count = 2 or count = 4 or count = 6 or count = 8 then
drawfilloval (250, 250, 50, 50, brightred)
reds (2) := reds (2) + 1
reds (5) := reds (5) + 1
reds (7) := reds (7) + 1
reds (8) := reds (8) + 1
end if
end two_and_two
procedure two_and_three
if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
drawfilloval (250, 350, 50, 50, brightblue)
blues (1) := blues (1) + 1
blues (5) := blues (5) + 1
elsif count = 2 or count = 4 or count = 6 or count = 8 then
drawfilloval (250, 350, 50, 50, brightred)
reds (1) := reds (1) + 1
reds (5) := reds (5) + 1
end if
end two_and_three
procedure three_and_one
if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
drawfilloval (350, 150, 50, 50, brightblue)
blues (3) := blues (3) + 1
blues (6) := blues (6) + 1
blues (7) := blues (7) + 1
elsif count = 2 or count = 4 or count = 6 or count = 8 then
drawfilloval (350, 150, 50, 50, brightred)
reds (3) := reds (3) + 1
reds (6) := reds (6) + 1
reds (7) := reds (7) + 1
end if
end three_and_one
procedure three_and_two
if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
drawfilloval (350, 250, 50, 50, brightblue)
blues (2) := blues (2) + 1
blues (6) := blues (6) + 1
elsif count = 2 or count = 4 or count = 6 or count = 8 then
drawfilloval (350, 250, 50, 50, brightred)
reds (2) := reds (2) + 1
reds (6) := reds (6) + 1
end if
end three_and_two
procedure three_and_three
if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
drawfilloval (350, 350, 50, 50, brightblue)
blues (1) := blues (1) + 1
blues (6) := blues (6) + 1
blues (8) := blues (8) + 1
elsif count = 2 or count = 4 or count = 6 or count = 8 then
drawfilloval (350, 350, 50, 50, brightred)
reds (1) := reds (1) + 1
reds (6) := reds (6) + 1
reds (8) := reds (8) + 1
end if
end three_and_three
loop
mousewhere (x, y, button)
if button = 1 and x >= 100 and x <= 200 and y >= 100 and y <= 200 then
one_and_one
elsif button = 1 and x >= 100 and x <= 200 and y >= 200 and y <= 300 then
one_and_two
elsif button = 1 and x >= 100 and x <= 200 and y >= 300 and y <= 400 then
one_and_three
elsif button = 1 and x >= 200 and x <= 300 and y >= 100 and y <= 200 then
two_and_one
elsif button = 1 and x >= 200 and x <= 300 and y >= 200 and y <= 300 then
two_and_two
elsif button = 1 and x >= 200 and x <= 300 and y >= 300 and y <= 400 then
two_and_three
elsif button = 1 and x >= 300 and x <= 400 and y >= 100 and y <= 200 then
three_and_one
elsif button = 1 and x >= 300 and x <= 400 and y >= 200 and y <= 300 then
three_and_two
elsif button = 1 and x >= 300 and x <= 400 and y >= 300 and y <= 400 then
three_and_three
else
put "Choose a box"
end if
if button = 1 then
delay (500)
count := count + 1
end if
exit when count = 11
locate (1, 1)
put "X coodinate at ", x
locate (2, 1)
put "Y coordinte at ", y
if blues (1) = 3 or blues (2) = 3 or blues (3) = 3 or blues (4) = 3 or blues (5) = 3 or blues (6) = 3 or blues (7) = 3 or blues (8) = 3 then
locate (28, 5)
put "Blue Wins!!"
locate (3, 1)
put " "
exit
elsif reds (1) = 3 or reds (2) = 3 or reds (3) = 3 or reds (4) = 3 or reds (5) = 3 or reds (6) = 3 or reds (7) = 3 or reds (8) = 3 then
locate (28, 5)
put "Red Wins!!!"
locate (3, 1)
put " "
exit
elsif count = 10 then
locate (28, 5)
put "Draw!"
locate (3, 1)
put " "
exit
end if
end loop
|