'I've wanted to make this game for decades and finally am able to!
'This game was made on August 14, 2019 by SierraKen.
'This is Freeware.
'Jan. 28, 2021 update: Choose at random who goes first.
'Jan. 29, 2021 update: Random colored grid, better looking X's, faster welcome screen, centered welcome screen better, made the ability to click to play a new game and another game,
'and added text colors.
'Jan. 30, 2021 update: Added background blue shades. Also added a score in the Title Bar. Turned the game into 3D - Thanks to B+ for the idea!
_TITLE "Tic-Tac-Toe by SierraKen" computer = 0
you = 0
PRINT " Play against the computer in this classic game of Tic-Tac-Toe." PRINT " Whoever gets 3 in a row wins." PRINT " Choose a sqace by using your mouse." PRINT " Computer chooses who goes first."
mouseWheel = 0
start:
ag$ = ""
t = 0
turn = 0
comp = 0
cl = cl + .5
cl = 0
'Draw Grid
'Vertical Lines
LINE (220 - xx
, 100 - xx
)-(240 - xx
, 410 - xx
), _RGB32(c1
- (xx
* 10), c2
- (xx
* 10), c3
- (xx
* 10)), BF
LINE (360 - xx
, 100 - xx
)-(380 - xx
, 410 - xx
), _RGB32(c1
- (xx
* 10), c2
- (xx
* 10), c3
- (xx
* 10)), BF
'Horizontal Lines
LINE (90 - xx
, 185 - xx
)-(510 - xx
, 205 - xx
), _RGB32(c1
- (xx
* 10), c2
- (xx
* 10), c3
- (xx
* 10)), BF
LINE (90 - xx
, 305 - xx
)-(510 - xx
, 325 - xx
), _RGB32(c1
- (xx
* 10), c2
- (xx
* 10), c3
- (xx
* 10)), BF
whosfirst:
Go:
mouseWheel = 0
checkwin:
'Check to see if you won.
turn = turn + 1
won:
a(tt) = 0
b(tt) = 0
you = you + 1
computer$
= STR$(computer
)_TITLE "You: " + you$
+ " Computer: " + comp$
t = 0
computer:
'Check to win.
'Last space gone.
'First space gone.
'Middle space gone.
'Check to block.
'Last space gone.
'First space gone.
'Middle space gone.
'Computer decides a random space.
computerchoice:
'Cat's Game
catsgame:
a(tt) = 0
b(tt) = 0
t = 0
'Check to see if the computer won.
check:
turn = turn + 1
t = 0
compwon:
a(tt) = 0
b(tt) = 0
t = 0
computer = computer + 1
_TITLE "You: " + you$
+ " Computer: " + comp$
'This part draws the computer's circle.
compspace1:
t = 0
b(1) = 1
CIRCLE (160 - xx
, 130 - xx
), 40 - s
, _RGB32(255 - (xx
* 10), 0, 0) compspace2:
t = 0
b(2) = 1
CIRCLE (300 - xx
, 130 - xx
), 40 - s
, _RGB32(255 - (xx
* 10), 0, 0) compspace3:
t = 0
b(3) = 1
CIRCLE (440 - xx
, 130 - xx
), 40 - s
, _RGB32(255 - (xx
* 10), 0, 0) compspace4:
t = 0
b(4) = 1
CIRCLE (160 - xx
, 250 - xx
), 40 - s
, _RGB32(255 - (xx
* 10), 0, 0) compspace5:
t = 0
b(5) = 1
CIRCLE (300 - xx
, 250 - xx
), 40 - s
, _RGB32(255 - (xx
* 10), 0, 0) compspace6:
t = 0
b(6) = 1
CIRCLE (440 - xx
, 250 - xx
), 40 - s
, _RGB32(255 - (xx
* 10), 0, 0) compspace7:
t = 0
b(7) = 1
CIRCLE (160 - xx
, 365 - xx
), 40 - s
, _RGB32(255 - (xx
* 10), 0, 0) compspace8:
t = 0
b(8) = 1
CIRCLE (300 - xx
, 365 - xx
), 40 - s
, _RGB32(255 - (xx
* 10), 0, 0) compspace9:
t = 0
b(9) = 1
CIRCLE (440 - xx
, 365 - xx
), 40 - s
, _RGB32(255 - (xx
* 10), 0, 0) 'This last part draws your X.
space1:
a(1) = 1
LINE (115 + s
- xx
, 104 - xx
)-(195 + s
- xx
, 169 - xx
), _RGB32(0, 255 - (xx
* 10), 0) LINE (195 + s
- xx
, 104 - xx
)-(115 + s
- xx
, 169 - xx
), _RGB32(0, 255 - (xx
* 10), 0) t = 1
space2:
a(2) = 1
LINE (255 + s
- xx
, 104 - xx
)-(335 + s
- xx
, 169 - xx
), _RGB32(0, 255 - (xx
* 10), 0) LINE (335 + s
- xx
, 104 - xx
)-(255 + s
- xx
, 169 - xx
), _RGB32(0, 255 - (xx
* 10), 0) t = 1
space3:
a(3) = 1
LINE (395 + s
- xx
, 104 - xx
)-(475 + s
- xx
, 169 - xx
), _RGB32(0, 255 - (xx
* 10), 0) LINE (475 + s
- xx
, 104 - xx
)-(395 + s
- xx
, 169 - xx
), _RGB32(0, 255 - (xx
* 10), 0) t = 1
space4:
a(4) = 1
LINE (110 + s
- xx
, 224 - xx
)-(190 + s
- xx
, 289 - xx
), _RGB32(0, 255 - (xx
* 10), 0) LINE (190 + s
- xx
, 224 - xx
)-(110 + s
- xx
, 289 - xx
), _RGB32(0, 255 - (xx
* 10), 0) t = 1
space5:
a(5) = 1
LINE (255 + s
- xx
, 224 - xx
)-(335 + s
- xx
, 289 - xx
), _RGB32(0, 255 - (xx
* 10), 0) LINE (335 + s
- xx
, 224 - xx
)-(255 + s
- xx
, 289 - xx
), _RGB32(0, 255 - (xx
* 10), 0) t = 1
space6:
a(6) = 1
LINE (395 + s
- xx
, 224 - xx
)-(475 + s
- xx
, 289 - xx
), _RGB32(0, 255 - (xx
* 10), 0) LINE (475 + s
- xx
, 224 - xx
)-(395 + s
- xx
, 289 - xx
), _RGB32(0, 255 - (xx
* 10), 0) t = 1
space7:
a(7) = 1
LINE (110 + s
- xx
, 339 - xx
)-(190 + s
- xx
, 404 - xx
), _RGB32(0, 255 - (xx
* 10), 0) LINE (190 + s
- xx
, 339 - xx
)-(110 + s
- xx
, 404 - xx
), _RGB32(0, 255 - (xx
* 10), 0) t = 1
space8:
a(8) = 1
LINE (255 + s
- xx
, 339 - xx
)-(335 + s
- xx
, 404 - xx
), _RGB32(0, 255 - (xx
* 10), 0) LINE (335 + s
- xx
, 339 - xx
)-(255 + s
- xx
, 404 - xx
), _RGB32(0, 255 - (xx
* 10), 0) t = 1
space9:
a(9) = 1
LINE (395 + s
- xx
, 339 - xx
)-(475 + s
- xx
, 404 - xx
), _RGB32(0, 255 - (xx
* 10), 0) LINE (475 + s
- xx
, 339 - xx
)-(395 + s
- xx
, 404 - xx
), _RGB32(0, 255 - (xx
* 10), 0) t = 1
playagain:
mouseWheel = 0