var sq1 : int := -999
var sq2 : int := -999
var sq3 : int := -999
var sq4 : int := -999
var sq5 : int := -999
var sq6 : int := -999
var sq7 : int := -999
var sq8 : int := -999
var sq9 : int := -999
var u1 : int := -999
var u2 : int := -999
var u3 : int := -999
var u4 : int := -999
var u5 : int := -999
var c1 : int := -999
var c2 : int := -999
var c3 : int := -999
var c4 : int := -999
var c5 : int := -999
var justonce : int
var cpmr : int
var hm : int
var command : string
function taken (x : int) : boolean
if x = c1 or x = c2 or x = c3 or x = c4 or x = c5 or x = u1 or x = u2 or x = u3 or x = u4 or x = u5 or
x < 1 or x > 9 then
result true
else
result false
end if
end taken
procedure plot_move (player : string (1), move : int)
cpmr := move
if cpmr = 1 %2
then
sq1 := 2
drawoval (52, 332, 40, 40, 3)
else
if cpmr = 2 %9
then
sq2 := 9
drawoval (197, 326, 40, 40, 3)
else
if cpmr = 3 %4
then
sq3 := 4
drawoval (326, 326, 40, 40, 3)
else
if cpmr = 4 %7
then
sq4 := 7
drawoval (57, 196, 40, 40, 3)
else
if cpmr = 5 %5
then
sq5 := 3
drawoval (197, 201, 40, 40, 3)
else
if cpmr = 6 %3
then
sq6 := 3
drawoval (329, 200, 40, 40, 3)
else
if cpmr = 7 %6
then
sq7 := 6
drawoval (60, 63, 40, 40, 3)
else
if cpmr = 8 %1
then
sq8 := 1
drawoval (198, 62, 40, 40, 3)
else
if cpmr = 9 %8
then
sq9 := 8
drawoval (327, 60, 40, 40, 3)
end if
end if
end if
end if
end if
end if
end if
end if
end if
if hm = 1 %2
then
sq1 := 2
drawline (23, 375, 97, 293, 4)
drawline (97, 369, 12, 302, 4)
else
if hm = 2 %9
then
sq2 := 9
drawline (151, 380, 233, 300, 4)
drawline (233, 375, 146, 291, 4)
else
hm := move
if hm = 3 %4
then
sq3 := 4
drawline (284, 383, 373, 286, 4)
drawline (376, 390, 284, 287, 4)
else
if hm = 4 %7
then
sq4 := 7
drawline (7, 256, 110, 158, 4)
drawline (111, 242, 8, 151, 4)
else
if hm = 5 %5
then
sq5 := 5
drawline (154, 245, 241, 161, 4)
drawline (242, 246, 153, 156, 4)
else
if hm = 6 %3
then
sq6 := 3
drawline (289, 246, 373, 153, 4)
drawline (376, 251, 283, 153, 4)
else
if hm = 7 %6
then
sq7 := 6
drawline (18, 104, 101, 23, 4)
drawline (106, 102, 6, 21, 4)
else
if hm = 8 %1
then
sq8 := 1
drawline (151, 108, 241, 12, 4)
drawline (223, 104, 155, 12, 4)
else
if hm = 9 %8
then
sq9 := 8
drawline (291, 104, 369, 22, 4)
drawline (359, 103, 284, 22, 4)
end if
end if
end if
end if
end if
end if
end if
end if
end if
end plot_move
procedure pc_move
Text.Locate (2, 50)
put "Computer's turn, please wait"
delay (450)
loop
randint (cpmr, 1, 9)
exit when not (taken (cpmr))
end loop
plot_move ("c", cpmr)
end pc_move
procedure user_move
Text.Locate (2, 50)
put "Your turn"
get hm
loop
exit when not (taken (cpmr))
end loop
plot_move ("u", hm)
end user_move
%below, i made it so that the introduction appears in the centre of the screen
procedure CentreText (s : string, row : int)
locate (row, (maxcol - length (s)) div 2)
put s
View.Update
end CentreText
procedure first_screen
colourback (black)
cls
colour (white)
delay (650)
CentreText ("IT'S THE TIC TAC TOE GAME!!!", maxrow div 2 - 7)
CentreText ("Created by Isaac K-S", maxrow div 2 - 5)
delay (700)
CentreText ("~Now Loading Game~", maxrow div 2 - 3)
delay (500)
CentreText (". . . ", maxrow div 2 - 1) %all this is just for fun, i wanted it to look cool, and make it look like it was actually loading somthing.
delay (500)
CentreText (" . . .", maxrow div 2 - 1)
delay (500)
CentreText (". . . ", maxrow div 2 - 1)
delay (500)
CentreText (" . . .", maxrow div 2 - 1)
delay (500)
CentreText (". . . ", maxrow div 2 - 1)
delay (500)
CentreText (" . . .", maxrow div 2 - 1)
delay (500)
CentreText (". . . ", maxrow div 2 - 1)
delay (500)
CentreText (" . . .", maxrow div 2 - 1)
delay (501)
CentreText ("READY!", maxrow div 2 - 1)
delay (650)
CentreText ("YAY", maxrow div 2 - 0)
end first_screen
procedure draw_screen
delay (500)
cls
colourback (10)
drawfillbox (135, 0, 131, maxy, 4)
drawfillbox (265, 0, 269, maxy, 4)
drawfillbox (385, 135, 0, 131, 4)
drawfillbox (385, 265, 0, 269, 4)
colour (black)
end draw_screen
%first_screen
draw_screen
plot_move |