Tic by Webber6th Mar 2011 18:35
|
---|
Summary Tic-Tac-Toe using a 3D text subroutine. No media needed. Description The 3D text subroutine can easily add 3D text to your game Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `Project: Tic-Tac-Toe with 3D text `Author: The Game Guy Rem Sets up the Game set display mode 1024,768,32 : sync on : sync rate 60 : color backdrop rgb(0,0,0) set camera range 0,.1,1000 : autocam off : set ambient light 0 set text font "modern" : set text size 12 : set text to bold : randomize timer() make light 1 : set light range 1,300 : color light 1,rgb(255,255,255) `Adds some lighting `Load Music "",1 : Loop Music `ADD YOUR MUSIC TO THE GAME Text3D$ as String `String used to create 3D text Dim D$(4)`Text Data Reading array TObj = 2 `A temporary object number for the 3D text (this can be any object number that is not used) Dim Rotate(7) as boolean `Difficulty select button rotating or not Dim TextAngle(7) as integer `Difficulty select button angles Dim XO(8) as integer `X's and O's positioning Turn as boolean `randomizes who goes first XOShift as boolean `randomizes who gets to be X's and who gets to be O's Position as byte `positions the X's and O's based on the mouse positions Difficulty as byte `gets the computers difficulty/ 2 player mode Cat as byte `checks for a cats game Winner as byte `checks for a winner X,O, or a Cats game Check as byte `Checks if the game board matchs the AI board Ran as integer `Checks for the amount of random moves that the computer can make Random as byte `Randomizes the computers moves ComMove as integer `Gets the computers move TitleWait as integer `Used to go back to the title screen after a while on the difficulty select screen Rem Title Screen Text Objects Text3D$ = "TIC-TAC-TOE" `this is what the 3D text will display Obj = 3 : Gosub Make_Object_3DText : Color Object Obj,rgb(255,0,0) Text3D$ = "3D" `Text 3D Obj = 4 : Gosub Make_Object_3DText : Color Object Obj,rgb(0,255,0) `Creates individual letters for the spinning text CLICK THE MOUSE Text3D$ = "C" : Obj = 5 : Gosub Make_Object_3DText : Text3D$ = "L" : Obj = 6 : Gosub Make_Object_3DText Text3D$ = "I" : Obj = 7 : Gosub Make_Object_3DText : Text3D$ = "C" : Obj = 8 : Gosub Make_Object_3DText Text3D$ = "K" : Obj = 9 : Gosub Make_Object_3DText : Text3D$ = "T" : Obj = 10: Gosub Make_Object_3DText Text3D$ = "H" : Obj = 11: Gosub Make_Object_3DText : Text3D$ = "E" : Obj = 12: Gosub Make_Object_3DText Text3D$ = "M" : Obj = 13: Gosub Make_Object_3DText : Text3D$ = "O" : Obj = 14: Gosub Make_Object_3DText Text3D$ = "U" : Obj = 15: Gosub Make_Object_3DText : Text3D$ = "S" : Obj = 16: Gosub Make_Object_3DText Text3D$ = "e" : Obj = 17: Gosub Make_Object_3DText Rem Colors Scales and hides the text CLICK THE MOUSE for Obj = 5 to 17 : Color Object Obj,rgb(0,0,255) : Scale object Obj,65,65,65 : hide object Obj : next Obj Rem Difficulty Select Text Text3D$ = "SELECT DIFFICULTY" : Obj = 18 : Gosub Make_Object_3DText : Color Object Obj,rgb(255,0,0) Scale object Obj,65,65,65 : turn object right Obj,90 : position object Obj,45,18,0 Text3D$ = "EASY" Obj = 19 : Gosub Make_Object_3DText : Scale object Obj,50,50,50 : turn object right Obj,90 : position object Obj,45,9,0 Text3D$ = "NORMAL" Obj = 20 : Gosub Make_Object_3DText : Scale object Obj,50,50,50 : turn object right Obj,90 : position object Obj,45,3,0 Text3D$ = "HARD" Obj = 21 : Gosub Make_Object_3DText : Scale object Obj,50,50,50 : turn object right Obj,90 : position object Obj,45,-3,0 Text3D$ = "IMPOSSIBLE" Obj = 22 : Gosub Make_Object_3DText : Scale object Obj,50,50,50 : turn object right Obj,90 : position object Obj,45,-9,0 Text3D$ = "2 PLAYER" Obj = 23 : Gosub Make_Object_3DText : Scale object Obj,50,50,50 : turn object right Obj,90 : position object Obj,45,-15,0 Text3D$ = "Quit" Obj = 24 : Gosub Make_Object_3DText : Scale object Obj,50,50,50 : turn object right Obj,90 : position object Obj,45,-21,0 Rem Draws the Game Board Obj = 25 : make object box Obj,50,50,2 : color object Obj,RGB(64,64,64) : position object Obj,0,0,-50 Obj = 26 : make object box Obj,2,50,4 : color object Obj,RGB(255,255,255) : position object Obj,-24,0,-49 Obj = 27 : make object box Obj,2,50,4 : color object Obj,RGB(255,255,255) : position object Obj,-8,0,-50 Obj = 28 : make object box Obj,2,50,4 : color object Obj,RGB(255,255,255) : position object Obj,8,0,-50 Obj = 29 : make object box Obj,2,50,4 : color object Obj,RGB(255,255,255) : position object Obj,24,0,-49 Obj = 30 : make object box Obj,50,2,4 : color object Obj,RGB(255,255,255) : position object Obj,0,-24,-49 Obj = 31 : make object box Obj,50,2,4 : color object Obj,RGB(255,255,255) : position object Obj,0,-8,-50 Obj = 32 : make object box Obj,50,2,4 : color object Obj,RGB(255,255,255) : position object Obj,0,8,-50 Obj = 33 : make object box Obj,50,2,4 : color object Obj,RGB(255,255,255) : position object Obj,0,24,-49 Rem Creates all of the X's Text3D$ = "X" Obj = 34 : Gosub Make_Object_3DText : Scale object Obj,225,225,225 : position object Obj,16,16,-48 for i = 35 to 42 : clone object i,34 : next i Obj = 33 for y = 1 to 3 : for x = 1 to 3 inc Obj,1 : Scale object Obj,225,225,225 : position object Obj,-x*16+32,-y*16+32,-48 : hide object Obj next x : next y Rem Creates all of the O's Text3D$ = "O" Obj = 43 : Gosub Make_Object_3DText : Scale object Obj,225,225,225 : position object Obj,16,16,-48 for i = 44 to 51 : clone object i,43 : next i Obj = 42 for y = 1 to 3 : for x = 1 to 3 inc Obj,1 : Scale object Obj,225,225,225 : position object Obj,-x*16+32,-y*16+32,-48 : hide object Obj next x : next y Rem Creates the 3D texts for telling who one Text3D$ = "X's Wins" : Obj = 52 : Gosub Make_Object_3DText : disable object zdepth Obj : hide object Obj : rotate object Obj,0,180,0 : Color object Obj,rgb(255,0,0) Text3D$ = "O's Wins" : Obj = 53 : Gosub Make_Object_3DText : disable object zdepth Obj : hide object Obj : rotate object Obj,0,180,0 : Color object Obj,rgb(255,0,0) Text3D$ = "CATS GAME" : Obj = 54 : Gosub Make_Object_3DText : disable object zdepth Obj : hide object Obj : rotate object Obj,0,180,0 : Color object Obj,rgb(255,0,0) Rem Creates more buttons Text3D$ = "BACK" : Obj = 55 : Gosub Make_Object_3DText : disable object zdepth Obj : hide object Obj : rotate object Obj,0,180,0 Text3D$ = "PLAY" : Obj = 56 : Gosub Make_Object_3DText : disable object zdepth Obj : hide object Obj : rotate object Obj,0,180,0 Scale object 55,50,50,50 : Scale object 56,50,50,50 Reset: Tac = 720 `variable for positioning the text at the start rotate camera 0,0,0,0 `adjust camera angle `TTTTT IIIII TTTTT L EEEEE SSSSS CCCCC RRRRR EEEEE EEEEE N N ` T I T L E S C R R E E NN N ` T I T L EEEE SSSSS C RRRRR EEEE EEEE N N N ` T I T L E S C R R E E N NN ` T IIIII T LLLLL EEEEE SSSSS CCCCC R R EEEEE EEEEE N N while mouseclick() = 0 or Tac <> 0 `loops until the mouse is clicked and Tac = 0 Gosub GetColor `Gets the rainbow colors for r, g, and b if Tac > 0 `stops the text when Tac = 0 Tac = Tac - 4 `Moves the text closer to the screen position object 3,0,12,Tac+45 : turn object right 3,2 `Positions and rotates the text "TIC-TAC-TOE" position object 4,0,0,Tac+45 : turn object right 4,2 `Positions and rotates the text "3D" else Space = 0 `variable used for the 2 spaces in the text "CLICK THE MOUSE" Rem "CLICK THE MOUSE" text for Obj = 5 to 17 Color object Obj,rgb(r,g,b)`adds rainbow colors to the text "CLICK THE MOUSE" if Obj = 10 then Space = 1 `adds a space if Obj = 13 then Space = 2 `adds another space ClickA# = ClickA# - .05 `angle of the rotating text if ClickA# < 0 then inc ClickA#,360 x# = cos(ClickA#+(Obj-5+Space)*22.5)*11 : z# = sin(ClickA#+(Obj-5+Space)*22.5)*11`x and z positions in the circle Rem rotates and positions the text around the circle rotate object Obj,0,-(ClickA#+(Obj-5+Space)*22.5)-90,0 : position object Obj,x#,-12,z#+45 : hide object Obj show object Obj`shows all of the text next Obj turn object right 4,.65 endif sync endwhile `The end of the Title Screen Loop `======================================================================================================================== Rem Turn Camera Right 90 degrees (Turns the camera to the difficuty select screen for i = 1 to 90 Gosub GetColor : for j = 19 to 24 : Color Object j,rgb(r,g,b) : next j : turn camera right 0,1 : sync next i DifficultySelect: for i = 0 to 5 : TextAngle(i) = 90 : next i `Adjusts angle of the button text rotate camera 0,0,90,0 `adjust camera angle `DDDD IIIII FFFFF FFFFF IIIII CCCCC U U L TTTTT Y Y SSSSS EEEEE L EEEEE CCCCC TTTTT `D D I F F I C U U L T Y Y S E L E C T `D D I FFFFF FFFFF I C U U L T Y SSSSS EEEE L EEEE C T `D D I F F I C U U L T Y S E L E C T `DDDD IIIII F F IIIII CCCCC UUUUU LLLLL T Y SSSSS EEEEE LLLLL EEEEE CCCCC T Rem The Difficulty select screen loop do Gosub GetColor `Gets the rainbow colors for r, g, and b rem adds rainbow colors to the buttons for i = 19 to 24 color object i,rgb(r,g,b) if Rotate(i-19) = 1 then color object i,rgb(-r+255,-g+255,-b+255)`inverts the colors when the mouse is over the button next i MX = MouseX() : MY = MouseY() `variables for the mouse positions (for the buttons) for i = 0 to 5 : Rotate(i) = 0 : next i `sets all of the buttons to stop rotating so that they stop rotating when the mouse is not over them Rem Loop for detecting if the mouse is over a button for i = 0 to 5 if MX > 300 and MX < 730 if MY > 213+i*85 and MY < 298+i*85 then Rotate(i) = 1 `Detects if the mouse is over a button endif if Rotate(i) = 1 then inc TextAngle(i),10 `rotates the button when the mouse is over it if Rotate(i) = 0 and TextAngle(i) <> 90 then inc TextAngle(i),10 `finnishes rotating a button when the mouse is not over it if TextAngle(i)>360 then dec TextAngle(i),360 next i for i = 0 to 5 : rotate object i+19,0,TextAngle(i),0 : next i `rotates the buttons Rem The Quit Button if Rotate(5) = 1 and mouseclick() = 1 then Goto Quit Rem Waits a while and then goes back to the title screen if MouseMoveX() <> 0 or MouseMoveY() <> 0 or MouseClick() <> 0 then TitleWait = 0 inc TitleWait,1 if TitleWait = 2000 for i = 3 to 17 : hide object i : next i for i = 1 to 90 Gosub GetColor for j = 19 to 24 : Color Object j,rgb(r,g,b) : next j turn camera left 0,1 sync next i rotate object 4,0,0,0 show object 3 : show object 4 : TitleWait = 0 goto Reset endif Rem The Difficulty Select Buttons for i = 0 to 4 if Rotate(i) = 1 and mouseclick() = 1 Difficulty = i `0 = Easy, 1 = Normal, 2 = Hard, 3 = Impossible, 4 = 2_Player goto Game endif next i sync loop `End of the difficulty select loop `======================================================================================================================== Game: Rem Turn Camera Right 90 degrees (Turns the camera to the difficuty select screen for i = 1 to 90 Gosub GetColor : for j = 19 to 24 : Color Object j,rgb(r,g,b) : next j : turn camera right 0,1 : sync next i ResetGame: for i = 6 to 7 : TextAngle(i) = 180 : next i `Adjusts angle of the button text if Winner > 0 `If X's, O's, or the Cat won a game show object Winner+51 `Show text based on who won show object 55 : show object 56 `Shows the BACK button and the PLAY button for i = 1 to 25 `Moves the text twords the screen Gosub GetColor `Gets the rainbow colors for r, g, and b for j = 52 to 54 : position object j,0,4,-435+i*16 : next j `Moves some of the text twords the screen for j = 34 to 42 : color object j,rgb(r,g,b) : color object j+9,rgb(-r+255,-g+255,-b+255) : next j `Colors all of the X's and O's position object 55,10,-8,-435+i*16 : color object 55,rgb(-r+255,-g+255,-b+255) `colors and moves the Back button twords the screen position object 56,-10,-8,-435+i*16 : color object 56,rgb(-r+255,-g+255,-b+255) `colors and moves the Play button twords the screen sync next i do `A loop used after a game with two buttons " Back and Play " MX = MouseX() : MY = MouseY() `variables for the mouse positions Rotate(6) = 0 : Rotate(7) = 0 if MX > 225 and MX < 425 and MY > 505 and MY < 555 then Rotate(6) = 1 if MX > 598 and MX < 802 and MY > 505 and MY < 555 then Rotate(7) = 1 for i = 6 to 7 if Rotate(i) = 1 then inc TextAngle(i),10 `rotates the button when the mouse is over it if Rotate(i) = 0 and TextAngle(i) <> 180 then inc TextAngle(i),10 `finnishes rotating a button when the mouse is not over it if TextAngle(i)>360 then dec TextAngle(i),360 `rotates the buttons rotate object i+49,0,TextAngle(i),0 next i Rem The Back Button if Rotate(6) = 1 and mouseclick() = 1 for i = 1 to 90 `rotates the camera and colors all of the text Gosub GetColor for j = 19 to 24 : Color Object j,rgb(r,g,b) : next j for j = 55 to 56 : Color Object j,rgb(r,g,b) : next j for j = 34 to 42 : Color Object j,rgb(r,g,b) : color object j+9,rgb(-r+255,-g+255,-b+255) : next j turn camera left 0,1 sync next i for j = 34 to 42 : hide object j : hide object j+9 : next j for j = 52 to 56 : hide object j : next j : Winner = 0 goto DifficultySelect endif Rem The play button if Rotate(7) = 1 and mouseclick() = 1 while mouseclick() <> 0 Gosub GetColor `Gets the rainbow colors for r, g, and b for i = 52 to 56 : color object i,rgb(r,g,b) : next i : sync endwhile goto NewGame: endif Rem Color all of the text Gosub GetColor `Gets the rainbow colors for r, g, and b for i = 34 to 42 : color object i,rgb(r,g,b) : color object i+9,rgb(-r+255,-g+255,-b+255) : next i color object 55,rgb(r,g,b) : color object 56,rgb(r,g,b) if Rotate(6) = 1 then color object 55,rgb(-r+255,-g+255,-b+255) if Rotate(7) = 1 then color object 56,rgb(-r+255,-g+255,-b+255) sync loop endif NewGame: for i = 52 to 56 : hide object i : next i `Hides all of the text Winner = 0 `Resets the Winner Variable Turn = rnd(1) `randomizes who goes first computer or player if Difficulty = 4 then Turn = 1 `The player allways goes first on 2 player mode XOShift = rnd(1) `randomizes who gets to be X's and who gets to be O's for i = 0 to 8 : XO(i) = 0 : next i `Erases all of the X's and O's rotate camera 0,0,180,0 `adjust camera angle `GGGGG AAAAA MMMMM EEEEE L OOOOO OOOOO PPPPP `G A A M M M E L O O O O P P `G GG AAAAA M M M EEEE L O O O O PPPPP `G G A A M M M E L O O O O P `GGGGG A A M M EEEEE LLLLL OOOOO OOOOO P do MX = MouseX() : MY = MouseY() `variables for the mouse positions Gosub GetColor `Gets the rainbow colors for r, g, and b Position = 0 `This variable tells what square the mouse is inside if MX > 205 and MX < 392 and MY > 75 and MY < 265 then Position = 1 if MX > 420 and MX < 605 and MY > 75 and MY < 265 then Position = 2 if MX > 632 and MX < 820 and MY > 75 and MY < 265 then Position = 3 if MX > 205 and MX < 392 and MY > 290 and MY < 476 then Position = 4 if MX > 420 and MX < 605 and MY > 290 and MY < 476 then Position = 5 if MX > 632 and MX < 820 and MY > 290 and MY < 476 then Position = 6 if MX > 205 and MX < 392 and MY > 505 and MY < 690 then Position = 7 if MX > 420 and MX < 605 and MY > 505 and MY < 690 then Position = 8 if MX > 632 and MX < 820 and MY > 505 and MY < 690 then Position = 9 Rem Colors and hides all of the X's and O's for i = 34 to 42 : color object i,rgb(r,g,b) : hide object i : color object i+9,rgb(-r+255,-g+255,-b+255) : hide object i+9 : next i `======================================================================================================================== rem if its the computers turn (Computer Artifical Intelligence) ComMove = 9 `variable for getting the computers move if Turn = 0 Sleep 100 `waits 1/10 of a second before the computer makes a move rem Goes in center if possible if Difficulty > 1 and ComMove = 9 and XO(4) = 0 then ComMove = 4 rem Wins the game on the next move if possible (normal difficulty and up) if Difficulty > 0 and ComMove = 9 for i = 0 to 2 if XO(0+i*3) = XOShift+1 and XO(1+i*3) = XOShift+1 and XO(2+i*3) = 0 then ComMove = 2+i*3 if XO(0+i*3) = XOShift+1 and XO(2+i*3) = XOShift+1 and XO(1+i*3) = 0 then ComMove = 1+i*3 if XO(1+i*3) = XOShift+1 and XO(2+i*3) = XOShift+1 and XO(0+i*3) = 0 then ComMove = 0+i*3 if XO(i) = XOShift+1 and XO(3+i) = XOShift+1 and XO(6+i) = 0 then ComMove = 6+i if XO(i) = XOShift+1 and XO(6+i) = XOShift+1 and XO(3+i) = 0 then ComMove = 3+i if XO(3+i) = XOShift+1 and XO(6+i) = XOShift+1 and XO(i) = 0 then ComMove = i next i if XO(0) = XOShift+1 and XO(4) = XOShift+1 and XO(8) = 0 then ComMove = 8 if XO(2) = XOShift+1 and XO(4) = XOShift+1 and XO(6) = 0 then ComMove = 6 if XO(2) = XOShift+1 and XO(6) = XOShift+1 and XO(4) = 0 then ComMove = 4 if XO(0) = XOShift+1 and XO(8) = XOShift+1 and XO(4) = 0 then ComMove = 4 if XO(4) = XOShift+1 and XO(6) = XOShift+1 and XO(2) = 0 then ComMove = 2 if XO(4) = XOShift+1 and XO(8) = XOShift+1 and XO(0) = 0 then ComMove = 0 endif Rem Blocks the player on hard mode or impossible mode (there is a 50% chance that it will block on normal mode) if Difficulty > 1 and ComMove = 9 or Difficulty = 1 and rnd(1) = 0 for i = 0 to 2 `Blocks the player Horizontaly and Verticaly if XO(0+i*3) = -XOShift+2 and XO(1+i*3) = -XOShift+2 and XO(2+i*3) = 0 then ComMove = 2+i*3 if XO(0+i*3) = -XOShift+2 and XO(2+i*3) = -XOShift+2 and XO(1+i*3) = 0 then ComMove = 1+i*3 if XO(1+i*3) = -XOShift+2 and XO(2+i*3) = -XOShift+2 and XO(0+i*3) = 0 then ComMove = 0+i*3 if XO(i) = -XOShift+2 and XO(3+i) = -XOShift+2 and XO(6+i) = 0 then ComMove = 6+i if XO(i) = -XOShift+2 and XO(6+i) = -XOShift+2 and XO(3+i) = 0 then ComMove = 3+i if XO(3+i) = -XOShift+2 and XO(6+i) = -XOShift+2 and XO(i) = 0 then ComMove = i next i rem Blocks the player diaginaly if XO(0) = -XOShift+2 and XO(4) = -XOShift+2 and XO(8) = 0 then ComMove = 8 if XO(2) = -XOShift+2 and XO(4) = -XOShift+2 and XO(6) = 0 then ComMove = 6 if XO(2) = -XOShift+2 and XO(6) = -XOShift+2 and XO(4) = 0 then ComMove = 4 if XO(0) = -XOShift+2 and XO(8) = -XOShift+2 and XO(4) = 0 then ComMove = 4 if XO(4) = -XOShift+2 and XO(6) = -XOShift+2 and XO(2) = 0 then ComMove = 2 if XO(4) = -XOShift+2 and XO(8) = -XOShift+2 and XO(0) = 0 then ComMove = 0 endif Rem AI that makes the computer impossible to beat and increases the chances of the computer winning Rem AI Board reading code [0 = Blank Spot, 1 = Com's X/O, 2 = Players X/O, 3 = (One of) the computers move(s)] if Difficulty = 3 and ComMove = 9 `if the difficulty is set to impossible `Blocks the player with a random corner move Board$ = "003012323" : Gosub GetMove : Board$ = "300210323" : Gosub GetMove Board$ = "323210300" : Gosub GetMove : Board$ = "323012003" : Gosub GetMove `Block by randomly choosing a side Board$ = "032313230" : Gosub GetMove : Board$ = "230313032" : Gosub GetMove `Block the player some other ways Board$ = "320010002" : Gosub GetMove : Board$ = "002210300" : Gosub GetMove Board$ = "200010023" : Gosub GetMove : Board$ = "003012200" : Gosub GetMove Board$ = "023010200" : Gosub GetMove : Board$ = "300210002" : Gosub GetMove Board$ = "002010320" : Gosub GetMove : Board$ = "200012003" : Gosub GetMove `Choooses random corners Board$ = "303020303" : Gosub GetMove : Board$ = "323010323" : Gosub GetMove : Board$ = "303212303" : Gosub GetMove `Chooses opposite corners Board$ = "002010300" : Gosub GetMove : Board$ = "200010003" : Gosub GetMove Board$ = "003010200" : Gosub GetMove : Board$ = "300010002" : Gosub GetMove `Chooses random open corners Board$ = "203020301" : Gosub GetMove : Board$ = "103020302" : Gosub GetMove Board$ = "301020203" : Gosub GetMove : Board$ = "302020103" : Gosub GetMove `Chooses a random corner for a sure win Board$ = "003210003" : Gosub GetMove : Board$ = "303010020" : Gosub GetMove Board$ = "300012300" : Gosub GetMove : Board$ = "020010303" : Gosub GetMove `Sets up a win for the next turn Board$ = "021013203" : Gosub GetMove : Board$ = "133210002" : Gosub GetMove Board$ = "302310120" : Gosub GetMove : Board$ = "200012331" : Gosub GetMove Board$ = "203013021" : Gosub GetMove : Board$ = "331012200" : Gosub GetMove Board$ = "120310302" : Gosub GetMove : Board$ = "002210133" : Gosub GetMove endif rem makes a random move if the computer has not made a move (easy mode always makes random moves) if ComMove = 9 repeat ComMove = rnd(8) until XO(ComMove) = 0 endif rem makes the computers move Xs/Os depending on the variable XOShift if XOShift = 0 XO(ComMove) = 1 : XOShift = 1 else XO(ComMove) = 2 : XOShift = 0 endif Turn = 1 `Makes it the players turn endif `======================================================================================================================== rem if its the players turn if Turn = 1 Rem Makes the players X/O visible depending on where the mouse is if Position > 0 if XOShift = 0 if XO(Position-1) = 0 then show object Position+33 else if XO(Position-1) = 0 then show object Position+42 endif Rem Makes the players move if mouseclick() = 1 and XO(Position-1) = 0 if XOShift = 0 `Changes the X's to O's or O's to X's XO(Position-1) = 1 : XOShift = 1 else XO(Position-1) = 2 : XOShift = 0 endif if Difficulty <> 4 then Turn = 0 `if the computer is playing then change turn to 0 (the computers turn) endif endif endif while mouseclick() = 1 : endwhile `Waits until the player lets go of the mouse `======================================================================================================================== Rem Checks for a Winner for i = 1 to 3 if XO(i*3-3) = 1 and XO(i*3-2) = 1 and XO(i*3-1) = 1 then Winner = 1 if XO(i*3-3) = 2 and XO(i*3-2) = 2 and XO(i*3-1) = 2 then Winner = 2 if XO(i-1) = 1 and XO(i+2) = 1 and XO(i+5) = 1 then Winner = 1 if XO(i-1) = 2 and XO(i+2) = 2 and XO(i+5) = 2 then Winner = 2 next i if XO(0) = 1 and XO(4) = 1 and XO(8) = 1 then Winner = 1 if XO(0) = 2 and XO(4) = 2 and XO(8) = 2 then Winner = 2 if XO(2) = 1 and XO(4) = 1 and XO(6) = 1 then Winner = 1 if XO(2) = 2 and XO(4) = 2 and XO(6) = 2 then Winner = 2 Rem Draw/Show all of the Xs/Os and Check for a cats game Cat = 0 `Variable for checking for a cats game for i = 0 to 8 if XO(i) = 1 then show object i+34 `Shows all of the visible X's if XO(i) = 2 then show object i+43 `Shows all of the visible O's if XO(i) > 0 then inc Cat,1 `Checks for a cats game if Cat = 9 and Winner = 0 then Winner = 3 `Cats Game next i if Winner > 0 then Goto ResetGame `If there is a winner or a cats game then reset the game sync loop `The end of the Game Loop `======================================================================================================================== Quit: end `The end of the program `AAAAA IIIII `A A I `AAAAA I `A A I `A A IIIII Rem Gets the computers move on impossible mode based on what is on the board GetMove: `0 = blank area on the board `1 = XOShift+1/computers x/0 `2 = -XOShift+2/players x/o `3 = random/the next move Ran = -1 `variable for getting random moves Check = 0 `variable for checking if the board matches with Board$ for i = 0 to 8 if mid$(Board$,i+1) = "3" and XO(i) = 0 then Ran = Ran + 1 `increases the random number if mid$(Board$,i+1) = "3" and XO(i) = 0 then Check = Check + 1 `checks if the spot is blank if mid$(Board$,i+1) = "0" and XO(i) = 0 then Check = Check + 1 `checks if the spot is blank if mid$(Board$,i+1) = "1" and XO(i) = XOShift+1 then inc Check,1 `checks if the com has an x/o their if mid$(Board$,i+1) = "2" and XO(i) = -XOShift+2 then inc Check,1 `checks if the player has an x/o their next i if Check = 9 `if Board$ matches the board if Ran > 0 then Random = rnd(Ran) `randomizes the computers move if Ran = 0 then Random = 0 `gets a specific move Ran = -1 `variable for getting the next move for i = 0 to 8 `gets the next move if mid$(Board$,i+1) = "3" then Ran = Ran + 1 if Ran = Random : ComMove = i : exit : endif `this gets the computers next move next i endif return `CCCCC OOOOO L OOOOO RRRRR `C O O L O O R R `C O O L O O RRRRR `C O O L O O R R `CCCCC OOOOO LLLLL OOOOO R R GetColor: if r=0 and g=0 and b=0 : r = 255 : g = 0 : b = 0 : c = 0 : endif`variables for rainbow colors for k = 1 to 3 if c=0 then g=g+1 if c=1 then r=r-1 if c=2 then b=b+1 if c=3 then g=g-1 if c=4 then r=r+1 if c=5 then b=b-1 if c=0 and g=255 then c=1 if c=1 and r=0 then c=2 if c=2 and b=255 then c=3 if c=3 and g=0 then c=4 if c=4 and r=255 then c=5 if c=5 and b=0 then c=0 next k return `33333 DDDD TTTTT EEEEE X X TTTTT ` e D D T E X X T `33333 D D T EEEE X T ` e D D T E X X T `33333 DDDD T EEEEE X X T Make_Object_3DText: `Text3D$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890`~!@#$%^&*()-_=+[]{}\|;:',.<>/?" `All of the text that can be used Letters = len(Text3D$) `Gets the amount of letters in the text LimbNum = 1 `Text object limb number Make Object cube TObj,1 : Make Mesh From Object TObj,2 `mesh used for creating all of the text Make Object Triangle Obj,0,0,0,0,0,0,0,0,0 `Object used as a center axis for the text for k = 1 to Letters `Loop for drawing the 3D text Letter$ = mid$(Text3D$,k) `Gets each letter in the text Rem The data used for drawing all of the text (XPosition,YPosition,XSize,YSize,ZAngle,Space creates the limb) if Letter$="A" or Letter$="a" then Text3DData$="-1.5,0,1,5,0 0,2,2,1,0 0,0,2,1,0 1.5,0,1,5,0 " if Letter$="B" or Letter$="b" then Text3DData$="-1.5,0,1,5,0 0,2,2,1,0 0,0,2,1,0 0,-2,2,1,0 1.5,0,1,3,0 1.25,1.75,.75,1.4142,45 1.25,-1.75,.75,1.4142,135 " if Letter$="C" or Letter$="c" then Text3DData$="-2,0,1,5,0 0,2,3,1,0 0,-2,3,1,0 " if Letter$="D" or Letter$="d" then Text3DData$="-1.5,0,1,5,0 0,2,2,1,0 0,-2,2,1,0 1.5,0,1,3,0 1.25,1.75,.75,1.4142,45 1.25,-1.75,.75,1.4142,135 " if Letter$="E" or Letter$="e" then Text3DData$="-1,0,1,5,0 .5,2,2,1,0 .5,0,2,1,0 .5,-2,2,1,0 " if Letter$="F" or Letter$="f" then Text3DData$="-1,0,1,5,0 .5,2,2,1,0 .5,0,2,1,0 " if Letter$="G" or Letter$="g" then Text3DData$="-2,0,1,5,0 .5,2,4,1,0 1.5,0,2,1,0 .5,-2,4,1,0 2,-1,1,1,0 " if Letter$="H" or Letter$="h" then Text3DData$="-1.5,0,1,5,0 0,0,2,1,0 1.5,0,1,5,0 " if Letter$="I" or Letter$="i" then Text3DData$="0,0,1,3,0 0,2,3,1,0 0,-2,3,1,0 " if Letter$="J" or Letter$="j" then Text3DData$="1,0,1,5,0 -1,-1,1,1,0 -.5,-2,2,1,0 " if Letter$="K" or Letter$="k" then Text3DData$="-1,0,1,5,0 1.1464,-2.1464,0.7072,0.7072,0 1.1464,2.1464,.7072,.7072,0 .086,1.086,3,1,45 .086,-1.086,1,3,45 " if Letter$="L" or Letter$="l" then Text3DData$="-1,0,1,5,0 0.5,-2,2,1,0 " if Letter$="M" or Letter$="m" then Text3DData$="-2,0,1,5,0 2,0,1,5,0 0,2,3,1,0 0,0,1,3,0 " if Letter$="N" or Letter$="n" then Text3DData$="-1.5,0,1,5,0 1.5,0,1,5,0 0,0,5.2915,1,-57.5 " if Letter$="O" or Letter$="o" then Text3DData$="-2,0,1,2,0 2,0,1,2,0 0,-2,2,1,0 0,2,2,1,0 -1.4,1.4,2.12,1,45 1.4,-1.4,2.12,1,45 1.4,1.4,1,2.12,45 -1.4,-1.4,1,2.12,45 " if Letter$="P" or Letter$="p" then Text3DData$="-1,0,1,5,0 .5,2,2,1,0 .5,0,2,1,0 1,1,1,1,0 " if Letter$="Q" or Letter$="q" then Text3DData$="1.4,-1.4,1,2.5,45 -2,0,1,2,0 2,0,1,2,0 0,-2,2,1,0 0,2,2,1,0 -1.4,1.4,2.12,1,45 1.4,-1.4,2.12,1,45 1.4,1.4,1,2.12,45 -1.4,-1.4,1,2.12,45 " if Letter$="R" or Letter$="r" then Text3DData$="-1,0,1,5,0 .5,2,2,1,0 .5,0,2,1,0 1,1,1,1,0 .3,-1.3,1,2.394,45 1.1464,-2.1464,.7072,.7072,0 " if Letter$="S" or Letter$="s" then Text3DData$="0,2,3,1,0 -1,1,1,1,0 0,0,3,1,0 1,-1,1,1,0 0,-2,3,1,0 " if Letter$="T" or Letter$="t" then Text3DData$="0,2,3,1,0 0,-.5,1,4,0 " if Letter$="U" or Letter$="u" then Text3DData$="-1.2,0,1,5,0 1.2,0,1,5,0 0,-2,2,1,0 " if Letter$="V" or Letter$="v" then Text3DData$="0,-2,1.25,1,0 -1,0,4.95,1,-70 1,0,4.95,1,70 " if Letter$="W" or Letter$="w" then Text3DData$="0,0,.6,1,0 -.9,-1,3.07,1,50 .9,-1,3.07,1,-50 -2,0,1,5,0 2,0,1,5,0 " if Letter$="X" or Letter$="x" then Text3DData$="-2.146,2.146,.707,0.707,0 2.146,2.146,0.707,0.707,0 -2.146,-2.146,0.707,0.707,0 2.146,-2.146,0.707,0.707,0 0,0,6.07,1,45 0,0,1,6.07,45 " if Letter$="Y" or Letter$="y" then Text3DData$="0,-1,1,3,0 1.085,1.085,3,1,45 2.146,2.146,.707,0.707,0 -1.085,1.085,1,3,45 -2.146,2.146,.707,0.707,0 " if Letter$="Z" or Letter$="z" then Text3DData$="0,2,3.5,1,0 0,-2,3.5,1,0 0,0,4.5,1,53 " if Letter$="0" then Text3DData$="0,2,3,1,0 0,-2,3,1,0 1,0,1,3,0 -1,0,1,3,0 " if Letter$="1" then Text3DData$="0,0,1,5,0 " if Letter$="2" then Text3DData$="0,2,3,1,0 1,1,1,1,0 0,0,3,1,0 -1,-1,1,1,0 0,-2,3,1,0 " if Letter$="3" then Text3DData$="1,0,1,5,0 -.5,2,2,1,0 -.5,0,2,1,0 -.5,-2,2,1,0 " if Letter$="4" then Text3DData$="0,0,3,1,0 1,1.5,1,2,0 -1,1.5,1,2,0 1,-1.5,1,2,0 " if Letter$="5" then Text3DData$="0,2,3,1,0 -1,1,1,1,0 0,0,3,1,0 1,-1,1,1,0 0,-2,3,1,0 " if Letter$="6" then Text3DData$="0,2,3,1,0 -1,0,1,3,0 0,0,3,1,0 1,-1,1,1,0 0,-2,3,1,0 " if Letter$="7" then Text3DData$="0,2,3,1,0 1,0,1,5,0 " if Letter$="8" then Text3DData$="-1,0,1,5,0 1,0,1,5,0 0,2,1,1,0 0,0,1,1,0 0,-2,1,1,0 " if Letter$="9" then Text3DData$="-1,1,1,3,0 0,2,1,1,0 0,0,1,1,0 1,0,1,5,0 " if Letter$="-" then Text3DData$="0,0,4,1,0 " if Letter$="+" then Text3DData$="0,0,4,1,0 0,0,1,4,0 " if Letter$="*" then Text3DData$="0,0,4,1,45 0,0,1,4,45 " if Letter$="/" then Text3DData$="0,0,5,1,45 " if Letter$="!" then Text3DData$="0,-2,.8,.8,0 0,-2,.8,.8,22.5 0,-2,.8,.8,45 0,-2,.8,.8,68 0,.8,1,3.4,0 " if Letter$="@" then Text3DData$="1,.7,3,1,0 1,-.7,3,1,0 -.8,0,1,2.4,0 2,1,1,3,0 0,2,5,1,0 -2,0,1,5,0 0,-2,5,1,0 " if Letter$="#" then Text3DData$="-1,0,1,5,0 1,0,1,5,0 0,1,5,1,0 0,-1,5,1,0 " if Letter$="$" then Text3DData$="0,2,3,1,0 -1,1,1,1,0 0,0,3,1,0 1,-1,1,1,0 0,-2,3,1,0 0,0,.5,6,0 " if Letter$="%" then Text3DData$="0,0,5,1,45 1.5,-1.5,1,1,0 1.5,-1.5,1,1,45 -1.5,1.5,1,1,0 -1.5,1.5,1,1,45 " if Letter$="^" then Text3DData$="-.71,1,3,1,45 .71,1,1,3,45 " if Letter$="&" then Text3DData$=".3,-.3,1,5,45 .6,-1.4,3,1,45 -.7,-1.5,1,2,45 0,0,4,1,45 0,1.5,3.2,1,0 " if Letter$="(" then Text3DData$="0,0,1,1.82,0 .287,1.5,1,1.7,-22.5 .287,-1.5,1,1.7,22.5 " if Letter$=")" then Text3DData$="0,0,1,1.82,0 -.287,1.5,1,1.7,22.5 -.287,-1.5,1,1.7,-22.5 " if Letter$="_" then Text3DData$="0,-2.3,6,.5,0 " if Letter$="=" then Text3DData$="0,1,4,1,0 0,-1,4,1,0 " if Letter$="\" then Text3DData$="0,0,1,5,45 " if Letter$="|" then Text3DData$="0,0,.5,5,0 " if Letter$="[" then Text3DData$="0,0,.5,5,0 .5,2.25,1,.5,0 .5,-2.25,1,.5,0 " if Letter$="]" then Text3DData$="0,0,.5,5,0 -.5,2.25,1,.5,0 -.5,-2.25,1,.5,0 " if Letter$="{" then Text3DData$="0,0,.5,5,0 .5,2.25,1,.5,0 .5,-2.25,1,.5,0 -.5,0,.5,.5,0 " if Letter$="}" then Text3DData$="0,0,.5,5,0 -.5,2.25,1,.5,0 -.5,-2.25,1,.5,0 .5,0,.5,.5,0 " if Letter$=":" then Text3DData$="0,1,1,1,0 0,-1,1,1,0 " if Letter$=";" then Text3DData$="0,1,1,1,0 0,-1,1,1,0 -.141,-1.8,1,1,-20 " if Letter$="," then Text3DData$="0,-1,1,1,0 -.141,-1.8,1,1,-20 " if Letter$="." then Text3DData$="0,-2,1,1,0 " if Letter$="'" then Text3DData$="0,1.5,1,2,0 " if Letter$="<" then Text3DData$="-2,0,1,1.25,0 0,1,1,4.95,-70 0,-1,1,4.95,70 " if Letter$=">" then Text3DData$="2,0,1,1.25,0 0,-1,1,4.95,-70 0,1,1,4.95,70 " if Letter$="?" then Text3DData$="0,-2,1,1,0 -1,1,1,1,0 1,1,1,1,0 0,2,1,1,0 -.65,1.65,1.414,1,45 .5,.2,1.83,1,45 .65,1.65,1,1.414,45 0,-.6,1,1,0 " if Letter$="`" then Text3DData$="0,2,.5,1,60 " if Letter$="~" then Text3DData$="-1,0,.5,1.44,-60 0,0,.5,1.44,60 1,0,.5,1.44,-60 " if Letter$=" " then goto SkipLetter TextDataSize = len(Text3DData$) `The amount of text used in the data for a specific letter Num = 0 `variable for reading the data for the 3D text Add Limb Obj,LimbNum,TObj `Creates the first object limb for a letter for i = 1 to TextDataSize `Loop for drawing a 3D letter/number/etc. if mid$(Text3DData$,i)="," then inc Num,1 `reads a comma in the data Rem Reads a space in the data Rem Positions the limbs, scales the limbs, and rotates the limbs based on what is in the text data (Draws the text) if mid$(Text3DData$,i)=" " Offset limb Obj,LimbNum,Val(D$(0))+(k-1)*6-Letters*3+3,Val(D$(1)),0 scale limb Obj,LimbNum,Val(D$(2))*100,Val(D$(3))*100,100 : rotate limb Obj,LimbNum,0,0,Val(D$(4)) if i <> TextDataSize `Creates the next limb if it is not the last limb inc LimbNum,1 : Add Limb Obj,LimbNum,2 endif Num = 0 : for j = 0 to 4 : D$(j) = "" : next j `Clears all of the data for the next limb endif Rem if the text data is not a space and is not a comma then read the number data if mid$(Text3DData$,i)<>" " and mid$(Text3DData$,i)<>"," then D$(Num)=D$(Num)+mid$(Text3DData$,i) next i inc LimbNum,1 SkipLetter: `Skips a letter if there is a space in the text next k Delete Object TObj `deletes the temporary object mesh used to create the text return `returns the the program |