How to Make Tic Tac Toe on Scratch - Create & Learn (2024)

Ready to learn how to make Tic Tac Toe on Scratch? With Scratch coding, you can bring this traditionally paper-and-pencil game for two players into the digital realm. In this game, each player makes one type of mark, either: X or O, and each player takes turns marking the spaces in a 3×3 grid with their mark. The winner is the player who gets three in a row!

So today, we'll guide you through simple steps to bring this game to life, and provide you with a few fun examples of ways to get creative with your version of the game. Let's get started!

By the way, we also have a special fun Scratch Pokemon game class right now. Join our live online award-winning Game Building class for expert guidance and fun Scratch projects every week:

How to make Tic Tac Toe on Scratch

In this tutorial, we will show you how to make a simple Tic Tac Toe game on Scratch using variables and lists. Follow along as we break down the logic to help you create your own Tic Tac Toe game. Here's what our completed project will look like.

1. One button, three costumes

There are three rows and three columns which makes for a total of 9 possible slots where X and O are placed. Let’s start with one Sprite: Button. Make two more costume: One for X and one for O. The third one will be used to represent an empty slot:

How to Make Tic Tac Toe on Scratch - Create & Learn (1)

2. Our platform

Simply right-click Button Sprite and select duplicate to make 8 more, then arrange them side by side into three rows and three columns:

How to Make Tic Tac Toe on Scratch - Create & Learn (2)

3. Start the game

Now is a good time to think of the first thing we should see once the game starts. We first want to see the third costume for the button (the one without the X/O). We also want to lock in a position for each button just in case they get shuffled around during the game:

How to Make Tic Tac Toe on Scratch - Create & Learn (3)

4. Whose turn?

Next, let’s create a variable to keep track of our turns. Since the game always starts with an X, we’ll use the mod block to display costume with an X if the number of clicks is odd, otherwise the costume with the O will show:

How to Make Tic Tac Toe on Scratch - Create & Learn (4)

5. List variables for X’s and O’s

Now that we can keep track of turns or XO’s, we need to create a list variable to store that information so that we can determine the winner. In Variables, click on Make a List for an X list and do the same for an O list. Then, use the “add ‘thing’ to” block to add to our lists. Do this for the rest of the Buttons but be sure to change the text for our list variables (x-button2; x-button3, o-button2, o-button3):

How to Make Tic Tac Toe on Scratch - Create & Learn (5)

6. Determine what’s inside and who won

And finally, it is time to check what’s inside of our list variables to announce a winner. There are a total of 8 possible ways to win (each row, each column, and diagonally for each side). If a list has one of the three descriptions that fall under a winning list, then we need to announce the winner. For example, if X list has x-button1, x-button2, and x-button3, which represent the first row of the game, then we have a winner. Use if/then condition to check all 8 possible solutions for both the X and the O list:

How to Make Tic Tac Toe on Scratch - Create & Learn (6)

Examples of Tic Tac Toe on Scratch

Now that you've created an awesome Tic Tac Toe game, here are a few variations to inspire your creativity.

1. A semi-challenging Tic-Tac-Toe by cairparavel

Want to play against a computer and have the chance to win? Check out this Tic Tac Toe game by cairparavel where the computer always goes first.

2. Stepping it up with Gato y Raton by carlosthan

Perhaps you like the opportunity to win against a computer, but you prefer to go first? Check out Gato y Raton by carlosthan – a Tic Tac Toe game that always waits for its opponents to go first. Just and don’t underestimate the brains behind the curtesy.

3. Unbeatable Tic-Tac-Toe by crazy_ted

Funny username but a very serious game. This Tic Tac Toe game truly lives up to its name: it is unbeatable!! It also uses cloud version and keeps a global score of wins, loses, and ties.

Now you know how to make Tic Tac Toe on Scratch

In this tutorial you’ve learned how to make a simple Tic Tac Toe game on Scratch using variables and lists. We’ve also covered how to switch back and forth between X and O based on turns, and we’ve implemented a way to determine a winner based on the 8 possible solutions for both X and O players.

Learn how to build games like this by taking our advanced Scratch course, designed by professionals from Google, Stanford, and MIT! You can also get started with any of our free coding classes for kids.

Ready for more fun? Up next, find out how to make a Pacman game on Scratch.

Written by Sandra Dizdarevic, a Create & Learn instructor with 6 years of experience teaching STEM to children in the 3rd through 11th grade. She has an Undergraduate as well as a Masters Degree in Management Information Systems from UNO.

How to Make Tic Tac Toe on Scratch - Create & Learn (2024)

FAQs

How to Make Tic Tac Toe on Scratch - Create & Learn? ›

The Tic-Tac-Toe Code is a secret code used by the Penguin Secret Agency and Elite Penguin Force as a means of communication among agents. In this code, spaces in three grids correspond to one of twenty-six letters in the English alphabet.

How to make a DIY tic-tac-toe game? ›

Making a Wooden Tic-Tac-Toe Game
  1. Step 1: Step 1: Create a Template for the "crosses" ...
  2. Step 2: Step 2: Find the Wood. ...
  3. Step 3: Step 3: Cut Out the Crosses. ...
  4. Step 4: Step 4: Make the Noughts. ...
  5. Step 5: Step 5: Sanding and Finishing the Noughts and the Crosses. ...
  6. Step 6: Step 6: the Board. ...
  7. Step 7: Step 7: Finished!!!!

What is the Tic Tac code? ›

The Tic-Tac-Toe Code is a secret code used by the Penguin Secret Agency and Elite Penguin Force as a means of communication among agents. In this code, spaces in three grids correspond to one of twenty-six letters in the English alphabet.

Is tic-tac-toe impossible mode possible? ›

Keep in mind that this is just for show; there's no way to beat the true Impossible mode! Still, if you're dead-set on winning, this is a simple way to beat Google's tic tac toe without exhausting yourself with tie after tie. Take a screenshot of your win to show other people that you beat the game.

How do you make a tic-tac-toe? ›

Build a Tic-Tac-Toe Game With Python and Tkinter
  1. Define Classes for the Players and Their Moves.
  2. Create a Class to Represent the Game Logic.
  3. Set Up the Abstract Game Board.
  4. Figure Out the Winning Combinations.

How do you make a big tic-tac-toe? ›

What to Do
  1. Use masking tape or chalk to make a tic-tac-toe grid on the floor (indoors) or the ground (outdoors).
  2. Decorate 5 plates with X's and 5 with O's.
  3. Staple each decorated plate to a plain plate to make disks.

Is tic-tac-toe always 3x3? ›

Rules for Tic-Tac-Toe

The game is played on a grid that's 3 squares by 3 squares. You are X , your friend (or the computer in this case) is O . Players take turns putting their marks in empty squares. The first player to get 3 of her marks in a row (up, down, across, or diagonally) is the winner.

How to make tic tac toe using HTML? ›

To get started, we will first need to create a basic HTML file. The HTML code provided below sets up the structure and layout of a Tic Tac Toe game. It includes a <table> element with a 3x3 grid of cells, which represent the spaces on the game board where players can place their markers (X's or O's).

How to code tic tac toe in Java? ›

Step 1: Create a 3×3 array to represent the tic tac toe board and fill it with dashes. We need to make a 2D array of characters, which can be x, o, or -. Now we have to fill our board with dashes. Hint: We can use a nested for loop to iterate through each position on our board.

Where is the Tic Tac unique code? ›

Each specially marked Tic Tac 24g pack will contain a unique code located inside the pack (“Unique Code”).

Top Articles
Latest Posts
Article information

Author: Madonna Wisozk

Last Updated:

Views: 6652

Rating: 4.8 / 5 (48 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Madonna Wisozk

Birthday: 2001-02-23

Address: 656 Gerhold Summit, Sidneyberg, FL 78179-2512

Phone: +6742282696652

Job: Customer Banking Liaison

Hobby: Flower arranging, Yo-yoing, Tai chi, Rowing, Macrame, Urban exploration, Knife making

Introduction: My name is Madonna Wisozk, I am a attractive, healthy, thoughtful, faithful, open, vivacious, zany person who loves writing and wants to share my knowledge and understanding with you.