Here is my "final" code. All I have left is to work out bugs.
Rem Project: Tic Tac Toe
Rem Created: Wednesday, February 8, 2012
Rem ***** Main Source File *****
'Chris McKenzie
'CIT 458
'Tic-Tac-Toe Assignment
'This just runs the title screen
IntroScreen:
CLS
xPos=320
yPos=200
textSize=20
dim board(3,3)
xScore = 0
oScore = 0
Set window on
Set window layout 1,1,1
Set Window title "Tic-Tac-Toe"
Set window position 100,200
Set window size 640,480
Set Text Font "Ariel"
Set Text Size textSize
center text xPos, yPos, "Written by Chris McKenzie"
wait 1000
CLS
wait 1000
center text xPos, yPos, "CIT 458 Developers bring you..."
wait 1000
while textSize <= 60
set Text Size textSize
CLS
inc textSize
wait 1
center text xPos, yPos, "Tic-Tac-Toe"
wait 1
endwhile
set text size 20
center text xPos, yPos+200, "Press any key to continue..."
Wait key
CLS
'This draws the game board and the background words
DrawBox:
set text size 50
center text 320, 20, "TIC-TAC-TOE"
line 170, 15, 470, 15
wait 1
line 470, 15, 470, 75
wait 1
line 470, 75, 170, 75
wait 1
line 170, 75, 170, 15
wait 1
set text size 40
center text 85, 75, "Player X"
center text 555, 75, "Player O"
set text size 30
center text 85, 250, "X Wins"
center text 555, 250, "O Wins"
set text size 20
set cursor 85, 285
print xScore
set cursor 555, 285
print oScore
set text size 15
center text 85, 125, "Left-click to make selection"
center text 555, 125, "Right-click to make selection"
Hl1 = 170
Hl2 = 170
while Hl1 <= 470
line 170, 250, Hl1, 250
inc Hl1
wait 1
endwhile
while Hl2 <= 470
line 170, 350, Hl2, 350
inc Hl2
wait 1
endwhile
Vl1 =300
Vl2 =300
while Vl1 <=450
line 270, 150, 270, Vl1
inc Vl1
wait 1
endwhile
while Vl2 <=450
line 370, 150, 370, Vl2
inc Vl2
wait 1
endwhile
'This sets up the actual game
PlayGame:
sync on
for y = 1 to 3
for x = 1 to 3
board(x, y) = 0
next
next
wait 2
sync
do
if mouseclick()=1 and mousex()>170 and mousey()<250 and mousex()<270 and mousey()>150 and board(1,1)=0
board(1,1)=1
line 195, 175, 245, 225
sync
line 245, 175, 195, 225
sync
endif
if mouseclick()=2 and mousex()>170 and mousey()<250 and mousex()<270 and mousey()>150 and board(1,1)=0
board(1,1)=4
circle 220, 200, 25
sync
endif
if mouseclick()=1 and mousex()>270 and mousey()<250 and mousex()<370 and mousey()>150 and board(1,2)=0
board(1,2)=1
line 295, 175, 345, 225
sync
line 345, 175, 295, 225
sync
endif
if mouseclick()=2 and mousex()>270 and mousey()<250 and mousex()<370 and mousey()>150 and board(1,2)=0
board(1,2)=4
circle 320, 200, 25
sync
endif
if mouseclick()=1 and mousex()>370 and mousey()<250 and mousex()<470 and mousey()>150 and board(1,3)=0
board(1,3)=1
line 395, 175, 445, 225
sync
line 445, 175, 395, 225
sync
endif
if mouseclick()=2 and mousex()>370 and mousey()<250 and mousex()<470 and mousey()>150 and board(1,3)=0
board(1,3)=4
circle 420, 200, 25
sync
endif
if mouseclick()=1 and mousex()>170 and mousey()<350 and mousex()<270 and mousey()>250 and board(2,1)=0
board(2,1)=1
line 195, 275, 245, 325
sync
line 245, 275, 195, 325
sync
endif
if mouseclick()=2 and mousex()>170 and mousey()<350 and mousex()<270 and mousey()>250 and board(2,1)=0
board(2,1)=4
circle 220, 300, 25
sync
endif
if mouseclick()=1 and mousex()>270 and mousey()<350 and mousex()<370 and mousey()>250 and board(2,2)=0
board(2,2)=1
line 295, 275, 345, 325
sync
line 345, 275, 295, 325
sync
endif
if mouseclick()=2 and mousex()>270 and mousey()<350 and mousex()<370 and mousey()>250 and board(2,2)=0
board(2,2)=4
circle 320, 300, 25
sync
endif
if mouseclick()=1 and mousex()>370 and mousey()<350 and mousex()<470 and mousey()>250 and board(2,3)=0
board(2,3)=1
line 395, 275, 445, 325
sync
line 445, 275, 395, 325
sync
endif
if mouseclick()=2 and mousex()>370 and mousey()<350 and mousex()<470 and mousey()>250 and board(2,3)=0
board(2,3)=4
circle 420, 300, 25
sync
endif
if mouseclick()=1 and mousex()>170 and mousey()<450 and mousex()<270 and mousey()>350 and board(3,1)=0
board(3,1)=1
line 195, 375, 245, 425
sync
line 245, 375, 195, 425
sync
endif
if mouseclick()=2 and mousex()>170 and mousey()<450 and mousex()<270 and mousey()>350 and board(3,1)=0
board(3,1)=4
circle 220, 400, 25
sync
endif
if mouseclick()=1 and mousex()>270 and mousey()<450 and mousex()<370 and mousey()>350 and board(3,2)=0
board(3,2)=1
line 295, 375, 345, 425
sync
line 345, 375, 295, 425
sync
endif
if mouseclick()=2 and mousex()>270 and mousey()<450 and mousex()<370 and mousey()>350 and board(3,2)=0
board(3,2)=4
circle 320, 400, 25
sync
endif
if mouseclick()=1 and mousex()>370 and mousey()<450 and mousex()<470 and mousey()>350 and board(3,3)=0
board(3,3)=1
line 395, 375, 445, 425
sync
line 445, 375, 395, 425
sync
endif
if mouseclick()=2 and mousex()>370 and mousey()<450 and mousex()<470 and mousey()>350 and board(3,3)=0
board(3,3)=4
circle 420, 400, 25
sync
endif
'This checks for a winner
if board(1,1)+board(1,2)+board(1,3)=3
CLS
sync
wait 1
CLS
set text size 60
center text 320, 240, "Player X Wins!"
sync
wait 3000
inc xScore
PlayAgain()
endif
if board(1,1)+board(1,2)+board(1,3)=12
CLS
sync
wait 1
CLS
set text size 60
center text 320, 240, "Player O Wins!"
sync
wait 3000
inc oScore
PlayAgain()
endif
if board(2,1)+board(2,2)+board(2,3)=3
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player X Wins!"
sync
wait 3000
inc xScore
PlayAgain()
endif
if board(2,1)+board(2,2)+board(2,3)=12
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player O Wins!"
sync
wait 3000
inc oScore
PlayAgain()
endif
if board(3,1)+board(3,2)+board(3,3)=3
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player X Wins!"
sync
wait 3000
inc xScore
PlayAgain()
endif
if board(3,1)+board(3,2)+board(3,3)=12
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player O Wins!"
sync
wait 3000
inc oScore
PlayAgain()
endif
if board(1,1)+board(2,1)+board(3,1)=3
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player X Wins!"
sync
wait 3000
inc xScore
PlayAgain()
endif
if board(1,1)+board(2,1)+board(3,1)=12
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player O Wins!"
sync
wait 3000
inc oScore
PlayAgain()
endif
if board(1,2)+board(2,2)+board(3,2)=3
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player X Wins!"
sync
wait 3000
inc xScore
PlayAgain()
endif
if board(1,2)+board(2,2)+board(3,2)=12
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player O Wins!"
sync
wait 3000
inc oScore
PlayAgain()
endif
if board(1,3)+board(2,3)+board(3,3)=3
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player X Wins!"
sync
wait 3000
inc xScore
PlayAgain()
endif
if board(1,3)+board(2,3)+board(3,3)=12
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player O Wins!"
sync
wait 3000
inc oScore
PlayAgain()
endif
if board(1,3)+board(2,2)+board(3,1)=3
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player X Wins!"
sync
wait 3000
inc xScore
PlayAgain()
endif
if board(1,3)+board(2,2)+board(3,1)=12
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player O Wins!"
sync
wait 3000
inc oScore
PlayAgain()
endif
if board(1,1)+board(2,2)+board(3,3)=3
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player X Wins!"
sync
wait 3000
inc xScore
PlayAgain()
endif
if board(1,1)+board(2,2)+board(3,3)=12
CLS
wait 1
sync
CLS
set text size 60
center text 320, 240, "Player O Wins!"
sync
wait 3000
inc oScore
PlayAgain()
endif
loop
'This checks to see of the player wants to play again
Function PlayAgain()
CLS
set cursor 310,240
set text size 20
input "Do you want to play again? (Y/N)", YesNo$
Sync
wait key
if keystate(21)=1 then goto DrawBox
if keystate(49)=1 then End
Cls
Sync
EndFunction
End
The only problem (that I am seeing anyway) is that when it asks me if I want to play again it doesn't work. Thanks in advance for any help.