This is just a tic tac toe game that I'm working on. For some reason a few things don't work in the game. If you could take a look at my code and just point out all of the silly noob mistakes I'm making that would be great!
Variables()
SetUpGame()
do
GetMove()
ExecuteMove()
FillSquare()
sync
loop
Function Variables()
Dim Board(9) `Declares board array
For t = 1 to 9 `Clears the board
Board(t) = 0
next t
PlayerTurn = 1 `Sets who goes first
PlayerWin = 0 `Sets the player win variable
EndFunction
Function SetUpGame()
REM Create playing grid
Line screen width()/3,100,screen width()/3,screen height()-100
Line (screen width()/3)*2,100,(screen width()/3)*2,screen height()-100
Line 100,screen height()/3,screen width()-100,screen height()/3
Line 100,(screen height()/3)*2,screen width()-100,(screen height()/3)*2
REM Print number places
set cursor 150,125
print "1"
set cursor 315,125
print "2"
set cursor 485,125
print "3"
set cursor 150,235
print "4"
set cursor 315,235
print "5"
set cursor 485,235
print "6"
set cursor 150,345
print "7"
set cursor 315,345
print "8"
set cursor 485,345
print "9"
REM Just some debugging code
X# = MouseX()
Y# = MouseY()
Z# = MouseZ()
print "X: ", X#
print "Y: ", Y#
print "Z: ", Z#
sync
EndFunction
Function GetMove()
ChooseAgain: `If invalid move
Input "Your move:",Choice `Get move from player
If Choice < 1 or Choice > 9 `Check if move is valid
GoSub ChooseAgain
EndIf
If Board(Choice) > 0 `Check if chosen square is not taken
Print "Square is already taken"
Wait 1700
GoSub ChooseAgain
Endif
If Choice = 0
Exit
EndIf
EndFunction
Function ExecuteMove()
REM Makes move for player
If PlayerTurn = 1
Board(Choice) = 1
EndIf
If PlayerTurn = 2
Board(Choice) = 2
EndIf
REM Switch player turns
If PlayerTurn = 1
PlayerTurn = 2
EndIf
If PlayerTurn = 2
PlayerTurn = 1
EndIf
EndFunction
Function FillSquare()
If Board(1) = 1
set cursor 150,125
print "X"
EndIf
If Board(2) = 1
set cursor 315,125
print "X"
EndIf
If Board(3) = 1
set cursor 485,125
print "X"
EndIf
If Board(4) = 1
set cursor 150,235
print "X"
EndIf
If Board(5) = 1
set cursor 315,235
print "X"
EndIf
If Board(6) = 1
set cursor 485,235
print "X"
EndIf
If Board(7) = 1
set cursor 150,345
print "X"
EndIf
If Board(8) = 1
set cursor 315,345
print "X"
EndIf
If Board(9) = 1
set cursor 485,345
print "X"
EndIf
REM ** All Circle Positions **
If Board(1) = 2
set cursor 150,125
print "O"
EndIf
If Board(2) = 2
set cursor 315,125
print "O"
EndIf
If Board(3) = 2
set cursor 485,125
print "O"
EndIf
If Board(4) = 2
set cursor 150,235
print "O"
EndIf
If Board(5) = 2
set cursor 315,235
print "O"
EndIf
If Board(6) = 2
set cursor 485,235
print "O"
EndIf
If Board(7) = 2
set cursor 150,345
print "O"
EndIf
If Board(8) = 2
set cursor 315,345
print "O"
EndIf
If Board(9) = 2
set cursor 485,345
print "O"
EndIf
EndFunction
P.S. This is unfinished and it can't tell if you've won and there is no AI yet.