Posted: Thu Jun 08, 2017 6:08 pm Post subject: tic tac toe help
I am trying to make a two player tic tac toe game but it seems that I cannot figure out how to fill in the spaces with X or O, each time switching when one is entered.
Posted: Thu Jun 08, 2017 6:22 pm Post subject: RE:tic tac toe help
What have you tried so far?
anon656
Posted: Thu Jun 08, 2017 6:45 pm Post subject: RE:tic tac toe help
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 then
elsif x >= 300 and x < 500 and y >= 100 and y <= 250 then
elsif x >= 500 and x < 700 and y >= 100 and y <= 250 then
elsif x >= 100 and x < 300 and y >= 250 and y <= 400 then
elsif x >= 300 and x < 500 and y >= 250 and y <= 400 then
elsif x >= 500 and x < 700 and y >= 250 and y <= 400 then
elsif x >= 100 and x < 300 and y >= 400 and y <= 550 then
elsif x >= 300 and x < 500 and y >= 400 and y <= 550 then
elsif x >= 500 and x < 700 and y >= 400 and y <= 550 then
end if
end if
end loop
anon656
Posted: Thu Jun 08, 2017 6:48 pm Post subject: RE:tic tac toe help
that is what i have so far
Insectoid
Posted: Thu Jun 08, 2017 6:51 pm Post subject: RE:tic tac toe help
What do you want to happen inside those if statements?
anon656
Posted: Thu Jun 08, 2017 6:54 pm Post subject: RE:tic tac toe help
display X or O but the problem is that i don't know how to make picX or picO switch. Also how do I make the program determine if the space is filled in.
anon656
Posted: Thu Jun 08, 2017 6:55 pm Post subject: RE:tic tac toe help
sorry about my wording. Im not a perfect English speaker.
Insectoid
Posted: Thu Jun 08, 2017 7:07 pm Post subject: RE:tic tac toe help
You've got 9 squares in tic tac toe. Why don't we start with 9 variables that store the state of each square?
Sponsor Sponsor
anon656
Posted: Thu Jun 08, 2017 7:12 pm Post subject: RE:tic tac toe help
so do i set the variables as Boolean?
Insectoid
Posted: Thu Jun 08, 2017 7:25 pm Post subject: RE:tic tac toe help
Why don't you try it and see how it goes?
anon656
Posted: Thu Jun 08, 2017 7:42 pm Post subject: RE:tic tac toe help
Posted: Thu Jun 08, 2017 7:43 pm Post subject: RE:tic tac toe help
when the space is filled it will be set as true
anon656
Posted: Thu Jun 08, 2017 7:52 pm Post subject: RE:tic tac toe help
var picX, picO, x, y, button : int
var a1, a2, a3, b1, b2, b3, c1, c2, c3 : boolean := false
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
Pic.Draw (picX, 150, 120, picCopy)
a1:=true
elsif x >= 300 and x < 500 and y >= 100 and y <= 250 a2=false then
Pic.Draw (picX, 350, 120, picCopy)
a2:=true
elsif x >= 500 and x < 700 and y >= 100 and y <= 250 a3=false then
Pic.Draw (picX, 550, 120, picCopy)
a3:=true
elsif x >= 100 and x < 300 and y >= 250 and y <= 400 b1=falsethen
Pic.Draw (picX, 150, 275, picCopy)
b1:=true
elsif x >= 300 and x < 500 and y >= 250 and y <= 400 b2=false then
Pic.Draw (picX, 350, 275, picCopy)
b2:=true
elsif x >= 500 and x < 700 and y >= 250 and y <= 400 b3=false then
Pic.Draw (picX, 550, 275, picCopy)
b3:=true
elsif x >= 100 and x < 300 and y >= 400 and y <= 550 c1=falsethen
Pic.Draw (picX, 150, 430, picCopy)
c1:=true
elsif x >= 300 and x < 500 and y >= 400 and y <= 550 c2=falsethen
Pic.Draw (picX, 350, 430, picCopy)
c2:=true
elsif x >= 500 and x < 700 and y >= 400 and y <= 550c3=false then
Pic.Draw (picX, 550, 430, picCopy)
c3:=true
end if
end if
end loop
anon656
Posted: Thu Jun 08, 2017 7:55 pm Post subject: RE:tic tac toe help
I am done the thing that checks if the space is filled. I need help with the turns now.
Can you also check if what I did is right? Thank you for the help and your patience.
Insectoid
Posted: Thu Jun 08, 2017 8:02 pm Post subject: RE:tic tac toe help