Ready to learn how to make Tic Tac Toe at the beginning? With the initial coding, you can bring this pleasant traditional paper-and-rensil game for two players into the digital domain. In this game, each player makes one type of sign, either: X or O, and each player takes turns marking the space in the 3 × 3 grid with their sign. The winner is a player who gets three consecutives!
So today, we will guide you and your child through simple steps to turn on this game. We will also give you some fun examples to be creative with your game version. Let’s start!
To explore more about the initial coding, join the initial class of online award winners for children, which are designed by professionals from Google, Stanford, and MIT, to enjoy expert guidelines when you make fun games.
How to make a tic tac toe at the beginning
In this tutorial, we will show you how to make a simple Tic Tic Toe game at the beginning using variables and lists. Follow together when we break logic to help you create your own Tic Tic Tic game. This is what will look like our project.
1. One button, three costumes
At Tic Tac Toe, there are three rows and three columns that make a total of 9 cells where x and O are placed. We will use the button called Sprite as the basis for our X and O. Create two more costumes: one for X and one for O. The third will be used to represent an empty slot. This will look like the picture below in the costume tab:

2. Game Platform
Just right -click (or click with two fingers simultaneously on the Chromebook) Sprite button below the initial stage and select duplicate to make 8 more, then set side by side into three rows and three columns. The image below shows you where you need to click right:

3. Start the game
Now is the right time to think of the first thing we want players to see that game begins. First of all we want to see the third empty costume for the button. We also want all buttons to return to their starting position to stand guard if they are dragged during the match:

4. whose turn?
Next, let’s make a variable to track our turn. Because the game always starts with X, we will use the modulo block from the mathematical operator category. The modulus block reports the remaining when the first number is divided into the second. Click here To learn more about Block Mod from Wiki Early! This is a very useful block that can be used to determine even or odd numbers in your project. For this game, we will use it to display costumes with x if the number of clicks is strange, if not when the number of clicks even, the costume with O will be displayed:

5. List of variables for x and o
Now we can track whose turn it, we need to make a list variable to store that information so that we can determine the winner. In the variable category, click create a list for the x list and do the same for the O. list then, use the “add ‘to” to “block to add to our list. Copy this code to each button but make sure to change the text for our list variable (X-Button2; X-Button3, O-Button2, O-Button3):

6. Determine what is inside and who wins
And finally, now is the time to check what is in our list variable to announce the winner at the end of the match. There are a total of 8 possible ways to win (each of the three rows, each of the three columns, and the two diagonal lines). We have to give the code to every individual winning condition to make the program can announce the right winner at the end of the match. For example, if the X list has X-Button1, X-Button2, and X-Button3, which represents the first line of the game, then we have a winner. Use if/then the condition to check all 8 possible solutions to list X and O. This code must be copied to each sprite so that it will declare the winner as soon as they win:

TIP: It might be useful for writing variable names on the Tic Tac Toe board on a piece of paper. Then you can draw a line through every condition of the winner that you have code. This will help you make sure you don’t miss anything and also help you check which numbers are calculated as victory!
Need help solving help? Here are some tips
Common problems and bugs on TIC tac toe tutorials and solutions
- Costumes do not switch properly:
- Problem: Sprite button does not switch to X or O when clicked.
- Solution: Make sure each sprite button has three costumes (empty, x, and o) and that
next costumeThe block is connected correctly towhen this sprite clickedincident. Logic verification in variables tracking turn.
- Draggled buttons:
- Problem: Exit button from the position during the gameplay.
- Solution: Use
go to x: y:Block to lock the position of the sprite each button at the beginning of the game. Ensure this block is included inwhen green flag clickedincident.
- Turn the inaccurate tracking:
- Problem: The game is not correctly alternating the turn between X and O.
- Solution: Make a variable named
turnTo track the number of clicks. Usemodoperators to determine their turn. Make sure to increase the variable correctly with each click.
- The winner is not determined correctly:
- Problem: The game does not accurately determine the winner.
- Solution: Make sure the list correctly keeps the position x and O. Check the logic at
if/thenThe block used to determine the combination of victory. Verification of each update list accurately in the correct position.
- Register Not Update:
- Problem: List x and o Not updating with each click.
- Solution: Check that double
add item to listBlocks are used correctly for each button. Make sure the correct list (X or O) is being updated based on the current turn.
- The game does not rearrange correctly:
- Problem: The game is not rearranged after winning or drawing.
- Solution: Add a
when green flag clickedThe event to rearrange all variables, lists, and button costumes. Make sure the game board returns to its initial situation.
Review the Key Programming Concepts that we use
- Sprite and costume:
- Sprite: Characters or objects in the game (for example, buttons for Tic Tac Toe).
- Costume: Different appearance for sprite. Here, each sprite button has three costumes (empty, x, and O).
- Variable:
- Turn the tracking: Variables to track the turn of the player today.
- List of variables: Used to store positions x and o to determine the winner.
- Program:
- When the green flag is clicked: Events to initiate games, prepare boards and rearrange variables.
- When this sprite is clicked: Events to handle player movements, switch costumes, and update the list.
- Control structure:
- If/then the statement: To check conditions, such as determining whether a player has won or whether the button has been clicked.
- Loop: To repeat actions, such as initializing the game board.
- Operator:
- MODULE (MOD): To take turns alternating between the player by checking whether the turn number is strange or even.
- List:
- Create and update the list: To track which boxes contain X or O, allow the game to check the winner’s combination.
Example of tic tac toe at the beginning
Now that you make an extraordinary Tic Tac Toe game, here are some variations to inspire your creativity.
1. Tic-tac-to-to-challenge by Cairparavel
Want to play against computers and have a chance to win? See Tic Tac Tac Tic Tic game by Cairparavel where the computer always goes first.
2. Submitting it with Gato Y Raton by Carlosthan
Maybe you like the chance to win against a computer, but you prefer to go first? Inspect Cats and mice By Carlosthan – Tic Tac Toe’s game who always waits for his opponent to leave first. Only and don’t underestimate the brain behind politeness.
3. Tic-tac-toe that is unbeaten by Crazy_ted
Funny user names but very serious games. This Tic Tac Tac game Really live according to its name: This is invincible !! It also uses the cloud version and maintains the global score of victory, loss and bond.
Create Tic Tac Toe at the beginning
In this tutorial, you have learned how to make a simple Tic Tac Toe game at the beginning using variables and lists. We have also discussed how to switch alternating between X and O based on turns, and we have applied ways to determine the winners based on 8 possible solutions for players X and O.
Learn how to build games like this by taking our Advanced Scratch Course, which is designed by professionals from Google, Stanford, and MIT! You can also start with our free coding class for children.
Ready for more fun? Find out how to make a Pacman game at the beginning.
Written by Sandra Dizdarevic, Create & Learn Instructor with 6 years the experience of teaching stem to children in grades 3 to 11. He has a bachelor’s degree and master in the management information system from Uno.
Game Online
Berita Olahraga
News
Berita Terkini
Berita Terbaru
Berita Teknologi
Seputar Teknologi
Drama Korea
Resep Masakan
Pendidikan
Berita Terbaru
Berita Terbaru
Berita Terbaru
A gaming hub can refer to a central platform or space dedicated to gaming, where players can access games, interact with other gamers, and enjoy related content.