Posted: Thu Jun 08, 2017 8:23 pm Post subject: RE:tic tac toe help
Turing:
var a1, a2, a3, b1, b2, b3, c1, c2, c3 : boolean := false
var turn : boolean := false %true for X and false for O
var turns : int := 1
var mainWin : int := Window.Open ("position:middle;center,graphics:800;650,nobuttonbar,title:tic-tac-toe")
proc userturns
if turns mod 2 = 0 then
turn := true
else
turn := false
end if
end userturns
proc userInput
userturns
var picX, picO, x, y, button : int
picX := Pic.FileNew ("picX.jpg")
picO := Pic.FileNew ("picO.jpg")
Draw.ThickLine (300, 100, 300, 550, 10, 7)
Draw.ThickLine (500, 100, 500, 550, 10, 7)
Draw.ThickLine (100, 400, 700, 400, 10, 7)
Draw.ThickLine (100, 250, 700, 250, 10, 7)
loop
Mouse.Where (x, y, button)
if button = 1 then
if x >= 100 and x <= 300 and y >= 100 and y <= 250 and a1 = false then
if turn = true then
Pic.Draw (picX, 150, 120, picCopy)
turn := false
else
Pic.Draw (picO, 150, 120, picCopy)
turn := true
end if
a1 := true
elsif x >= 300 and x < 500 and y >= 100 and y <= 250 and a2 = false then
if turn = true then
Pic.Draw (picX, 350, 120, picCopy)
turn := false
else
Pic.Draw (picO, 350, 120, picCopy)
turn := true
end if
a2 := true
elsif x >= 500 and x < 700 and y >= 100 and y <= 250 and a3 = false then
if turn = true then
Pic.Draw (picX, 550, 120, picCopy)
turn := false
else
Pic.Draw (picO, 550, 120, picCopy)
turn := true
end if
a3 := true
elsif x >= 100 and x < 300 and y >= 250 and y <= 400 and b1 = false then
if turn = true then
Pic.Draw (picX, 150, 275, picCopy)
turn := false
else
Pic.Draw (picO, 150, 275, picCopy)
turn := true
end if
b1 := true
elsif x >= 300 and x < 500 and y >= 250 and y <= 400 and b2 = false then
if turn = true then
Pic.Draw (picX, 350, 275, picCopy)
turn := false
else
Pic.Draw (picO, 350, 275, picCopy)
turn := true
end if
b2 := true
elsif x >= 500 and x < 700 and y >= 250 and y <= 400 and b3 = false then
if turn = true then
Pic.Draw (picX, 550, 275, picCopy)
turn := false
else
Pic.Draw (picO, 550, 275, picCopy)
turn := true
end if
b3 := true
elsif x >= 100 and x < 300 and y >= 400 and y <= 550 and c1 = false then
if turn = true then
Pic.Draw (picX, 150, 430, picCopy)
turn := false
else
Pic.Draw (picO, 150, 430, picCopy)
turn := true
end if
c1 := true
elsif x >= 300 and x < 500 and y >= 400 and y <= 550 and c2 = false then
if turn = true then
Pic.Draw (picX, 350, 430, picCopy)
turn := false
else
Pic.Draw (picO, 350, 430, picCopy)
turn := true
end if
c2 := true
elsif x >= 500 and x < 700 and y >= 400 and y <= 550 and c3 = false then
Pic.Draw (picX, 550, 430, picCopy)
if turn = true then
Pic.Draw (picX, 550, 430, picCopy)
turn := false
else
Pic.Draw (picO, 550, 430, picCopy)
turn := true
end if
c3 := true
end if
end if
end loop
end userInput
userInput
Sponsor Sponsor
anon656
Posted: Thu Jun 08, 2017 8:27 pm Post subject: RE:tic tac toe help
How can i make something that figures out who wins?
Insectoid
Posted: Fri Jun 09, 2017 4:20 am Post subject: RE:tic tac toe help