Answered by:
Small BASICTicTacToe Game

CAN SOME ONE HELP ME WITH A TIC TAC TOE GAME. I HAVE THE GRID UP AND EVERYTHING I JUST DONT HAVE ANY THING TO PLAY THE GAME WITH EG. THE O'S OR X'S MOVING AND PLACING THEM ON THE GRID. THIS IS A SERIOUS PROBLEM AND IF I DONT GET IT I WILL FAIL THIS COARSE. HELPP ME IF YOU CARE ABOUT HUMANITY. PLEASE. I'M BEGGING YOU.
Question
Answers

Here, I think this is what you are looking for. It doesn't show who wins yet, though. I just modified your code.
TextWindow.BackgroundColor= "Yellow" TextWindow.Clear () TextWindow.ForegroundColor= "Black" TextWindow.WriteLine ("Welcome to the game 'TicTacToe'! Enter your name here: ") name = TextWindow.Read () TextWindow.WriteLine ("Here are the rules to play TicTacToe " + name ) TextWindow.WriteLine ("Rules: 1) Pick to either be player X or player O. 2) One player will choose to go first and place their symbols in only one of the 9 spaces on the grid. 3) As the second player goes, they are trying to prevent each other from getting three of the same symbols in a row. 4) Continue step 2 & 3 until all nine spaces are full. If no one has won by getting three symbols in a row, it is called a draw or 'Cats Game'. 5) Then play again.") TextWindow.WriteLine (" Hey " + name ) TextWindow.WriteLine (" Do you know how to play?") answer = TextWindow.Read() If (answer = "yes") Then TextWindow.WriteLine ("Perfect! Let's play!") EndIf If (answer = "no") Then TextWindow.WriteLine ("You are really dumb " + name + ", and are going no where in life") EndIf Program.Delay (2000) TextWindow.Hide () GraphicsWindow.BackgroundColor = "Red" GraphicsWindow.Title = "TicTacToe" GraphicsWindow.Height = 600 GraphicsWindow.Width = 900 rows= 3 columns= 3 size= 190 offsetX = (GraphicsWindow.Widthrows*size)/2 offsetY= (GraphicsWindow.Heightcolumns*size)/2 For r = 1 To rows For c = 1 To columns GraphicsWindow.BrushColor = "White" boxes[r][c] = Shapes.AddRectangle(size,size ) Shapes.Move(boxes[r][c], offsetX + (r1)*size, offsetY + (c1)*size ) EndFor EndFor turn = "X" GraphicsWindow.MouseDown = MouseDown GraphicsWindow.FontSize = size GraphicsWindow.BrushColor = "Blue" Sub MouseDown amount_turns = amount_turns+1 selectedx = Math.Ceiling((GraphicsWindow.MouseXoffsetX)/size) selectedy = Math.Ceiling((GraphicsWindow.MouseYoffsetY)/size) TextWindow.WriteLine(selectedx) TextWindow.WriteLine(selectedy) Text[amount_turns] = Shapes.AddText(turn) Shapes.Move(Text[amount_turns],Shapes.GetLeft(boxes[selectedx][selectedy])+5,Shapes.GetTop(boxes[selectedx][selectedy])+5) TextWindow.WriteLine(Shapes.GetLeft(boxes[selectedx][selectedy])) TextWindow.WriteLine(Shapes.GetTop(boxes[selectedx][selectedy])) If turn = "X" Then turn = "O" Else turn = "X" EndIf EndSub
I am a 10 year old that loves math, games, and computers. 'Binary is as easy as 1, 10, 11.'
 Proposed as answer by Math Man Wednesday, November 21, 2012 7:05 PM
 Marked as answer by Ed Price  MSFTMicrosoft employee, Owner Friday, November 30, 2012 7:42 AM
All replies

Here, I think this is what you are looking for. It doesn't show who wins yet, though. I just modified your code.
TextWindow.BackgroundColor= "Yellow" TextWindow.Clear () TextWindow.ForegroundColor= "Black" TextWindow.WriteLine ("Welcome to the game 'TicTacToe'! Enter your name here: ") name = TextWindow.Read () TextWindow.WriteLine ("Here are the rules to play TicTacToe " + name ) TextWindow.WriteLine ("Rules: 1) Pick to either be player X or player O. 2) One player will choose to go first and place their symbols in only one of the 9 spaces on the grid. 3) As the second player goes, they are trying to prevent each other from getting three of the same symbols in a row. 4) Continue step 2 & 3 until all nine spaces are full. If no one has won by getting three symbols in a row, it is called a draw or 'Cats Game'. 5) Then play again.") TextWindow.WriteLine (" Hey " + name ) TextWindow.WriteLine (" Do you know how to play?") answer = TextWindow.Read() If (answer = "yes") Then TextWindow.WriteLine ("Perfect! Let's play!") EndIf If (answer = "no") Then TextWindow.WriteLine ("You are really dumb " + name + ", and are going no where in life") EndIf Program.Delay (2000) TextWindow.Hide () GraphicsWindow.BackgroundColor = "Red" GraphicsWindow.Title = "TicTacToe" GraphicsWindow.Height = 600 GraphicsWindow.Width = 900 rows= 3 columns= 3 size= 190 offsetX = (GraphicsWindow.Widthrows*size)/2 offsetY= (GraphicsWindow.Heightcolumns*size)/2 For r = 1 To rows For c = 1 To columns GraphicsWindow.BrushColor = "White" boxes[r][c] = Shapes.AddRectangle(size,size ) Shapes.Move(boxes[r][c], offsetX + (r1)*size, offsetY + (c1)*size ) EndFor EndFor turn = "X" GraphicsWindow.MouseDown = MouseDown GraphicsWindow.FontSize = size GraphicsWindow.BrushColor = "Blue" Sub MouseDown amount_turns = amount_turns+1 selectedx = Math.Ceiling((GraphicsWindow.MouseXoffsetX)/size) selectedy = Math.Ceiling((GraphicsWindow.MouseYoffsetY)/size) TextWindow.WriteLine(selectedx) TextWindow.WriteLine(selectedy) Text[amount_turns] = Shapes.AddText(turn) Shapes.Move(Text[amount_turns],Shapes.GetLeft(boxes[selectedx][selectedy])+5,Shapes.GetTop(boxes[selectedx][selectedy])+5) TextWindow.WriteLine(Shapes.GetLeft(boxes[selectedx][selectedy])) TextWindow.WriteLine(Shapes.GetTop(boxes[selectedx][selectedy])) If turn = "X" Then turn = "O" Else turn = "X" EndIf EndSub
I am a 10 year old that loves math, games, and computers. 'Binary is as easy as 1, 10, 11.'
 Proposed as answer by Math Man Wednesday, November 21, 2012 7:05 PM
 Marked as answer by Ed Price  MSFTMicrosoft employee, Owner Friday, November 30, 2012 7:42 AM


here is the code...not perfect but mostly there
GraphicsWindow.MouseDown = myMouseDown
' This section Maximizes the window
GraphicsWindow.Clear()
GraphicsWindow.Title = "Small Basic Tic Tac Toe"
GraphicsWindow.Height = 190*3
GraphicsWindow.Width = 190*3
GraphicsWindow.Top = 0
GraphicsWindow.Left = 0
GraphicsWindow.CanResize = "False"
GraphicsWindow.PenWidth = 1/2rows= 3
columns= 3
size= 190offsetX = (GraphicsWindow.Widthrows*size)/2
offsetY= (GraphicsWindow.Heightcolumns*size)/2For r = 1 To rows
For c = 1 To columns
boxes[r][c] = Shapes.AddRectangle(size,size)
Shapes.Move(boxes[r][c], offsetX + (r1)*size, offsetY + (c1)*size )
EndFor
EndForturn = "X"
GraphicsWindow.FontSize = size
GraphicsWindow.BrushColor = "White"inc = 1
Sub myMouseDown
If inc <= 9 then
amount_turns = amount_turns + 1
selectedx = Math.Ceiling((GraphicsWindow.MouseXoffsetX)/size)
selectedy = Math.Ceiling((GraphicsWindow.MouseYoffsetY)/size)
Text[amount_turns] = Shapes.AddText(turn)
x = Shapes.GetLeft(boxes[selectedx][selectedy])+30
y = Shapes.GetTop(boxes[selectedx][selectedy])30
Shapes.Move(Text[amount_turns],x,y)
If turn = "X" Then
turn = "O"
Else
turn = "X"
EndIf
inc = inc + 1
' PC Coordinates
If x + "," + y = "35,25" Then
A = turn
ElseIf x + "," + y = "225,25" Then
B = turn
Elseif x + "," + y = "415,25" Then
C = turn
Elseif x + "," + y = "35,165" Then
D = turn
Elseif x + "," + y = "225,165" Then
E = turn
Elseif x + "," + y = "415,165" Then
F = turn
Elseif x + "," + y = "35,355" Then
G = turn
Elseif x + "," + y = "225,355" Then
H = turn
Elseif x + "," + y = "415,355" Then
I = turn
EndIf
' Web CoOrdinates
If x + "," + y = "30,30" Then
A = turn
ElseIf x + "," + y = "220,30" Then
B = turn
Elseif x + "," + y = "410,30" Then
C = turn
Elseif x + "," + y = "30,160" Then
D = turn
Elseif x + "," + y = "220,160" Then
E = turn
Elseif x + "," + y = "410,160" Then
F = turn
Elseif x + "," + y = "30,155" Then
G = turn
Elseif x + "," + y = "220,350" Then
H = turn
Elseif x + "," + y = "410,350" Then
I = turn
EndIf
' Check to see if anyone has won
If turn = "X" Then
turn = "O"
Else
turn = "X"
Endif
If A = B And B = c Then
GraphicsWindow.ShowMessage("User " + Turn + " is the winner!!!", "Winner")
ElseIf D = E and E = F Then
GraphicsWindow.ShowMessage("User " + Turn + " is the winner!!!", "Winner")
ElseIf G = H and H = I Then
GraphicsWindow.ShowMessage("User " + Turn + " is the winner!!!", "Winner")
ElseIf A = D and D = G Then
GraphicsWindow.ShowMessage("User " + Turn + " is the winner!!!", "Winner")
ElseIf B = E and E = H Then
GraphicsWindow.ShowMessage("User " + Turn + " is the winner!!!", "Winner")
ElseIf C = F and F = I Then
GraphicsWindow.ShowMessage("User " + Turn + " is the winner!!!", "Winner")
ElseIf A = E and E = I Then
GraphicsWindow.ShowMessage("User " + Turn + " is the winner!!!", "Winner")
ElseIf G = E and E = C Then
GraphicsWindow.ShowMessage("User " + Turn + " is the winner!!!", "Winner")
EndIf
If turn = "O" Then
turn = "X"
Else
turn = "O"
Endif
Else
' Do Nothing
Endif
EndSub Proposed as answer by Ed Price  MSFTMicrosoft employee, Owner Wednesday, November 28, 2012 12:56 AM