How To Make Basic & Advanced Math Games In Scratch

How To Make Math Game In Scratch & Level Up Your Skills

By Team BrightChamps
Home » Code for Kids Corner » How To Make Math Game In Scratch & Level Up Your Skills

Coding and math have an unbreakable bond that none of us can deny. We have always been fascinated by the combination of Math and Coding since the beginning of coding. 

Have you ever attempted to create a basic or advanced Math game in Scratch

Do you want to introduce scratch coding for kids.

We begin with Math projects to understand the fundamentals of coding because they are very compatible and have a long history with coding. 

Let’s try to make a basic & advanced Math project in Scratch!

Basic & Advanced Math Games In Scratch 

Now, you’re probably wondering where to begin. Don’t worry; we’ve got your back wherever you start.

These basic and advanced Math Scratch games can even go on for a long time, as the more Math topics you learn, the more questions you can add to your Math game.

Today, I’ll take you step by step through creating a basic & advanced Math game in Scratch.

Let’s begin with a basic Math game project. In this project, we will create a game using two sprites. 

The first sprite will be our player, and the second sprite will be our opponent, and they will compete in a race. The project will resemble the image below:

Math Games In Scratch

Here, we’ll start with a simple Math calculation question, and with each correct answer, the cat (our player) will advance a step. 

Meanwhile, the Dog (Opponent) will advance with each incorrect answer. Finally, whoever crosses the finish line first wins the game. 

Steps To Make Basic & Advanced Math Game In Scratch 

Sounds interesting? Let’s hop right into it and practice this Math game by following the given steps below: 

  • First, visit https://Scratch.mit.edu/ to sign in, click on the top right corner where it says Sign in, and enter your ID and password as shown image below. 
Math Games In Scratch
  • Once you are logged in, click on Create option that you can see on the top left corner of the menu bar. 
Math Games In Scratch

Note – We can create projects without logging in, but you won’t be able to share them on Scratch or with anyone, and you won’t be able to save them online. This means that if they disappear by accident, they’re gone for good. And you don’t want to waste your time, so always sign in first.

  • Now, you must be able to see the creator’s screen of Scratch so let’s have a quick introduction to this screen.  

We have Block Palette: which contains all blocks that we might use when we code for the project. 

Math Games In Scratch

Script area: where we place all the blocks for coding.

Math Games In Scratch

Stage: where we see the output of our project.

Math Games In Scratch

Sprites’ property section: where we see the details related to the selected sprite.

Math Games In Scratch
  • Now, Let’s add sprites of our choice. First, add a sprite to be the player by clicking on Choose a sprite option.
Math Games In Scratch
  • Now select the sprite you want to go with from the screen that looks like the one shown in the image below.
Math Games In Scratch
  • Repeat step 5 and add another sprite to be the opponent. 
  • Now, we’ll add the third sprite i.e. the finish line. We can choose a sprite that matches the pattern of the finish line or draw it ourselves by selecting the print option from the add sprite menu.
Math Games In Scratch
  • Now you see a screen like the one below to draw your sprite.
Math Games In Scratch
  • You can draw simple patterns using the square option.
Math Games In Scratch
  • Now add a backdrop by clicking on the draw option to draw tracks to give an attractive background or choose any backdrop from Choose a backdrop option.
Math Games In Scratch
  • Now let’s go back to the code section. First, we will create variables that will be useful in this project.  
  • Click the variables option from the block palette and create four variables. 
Math Games In Scratch
  • Now, we have one Operators option in the block palette that we can use to add mathematical questions. Because we will be doing basic calculations, we will use blocks for addition, subtraction, multiplication, etc. 

Here is a list of operators that will be used in both the basic and advanced Math games:

Math Games In Scratch
  • Now, click on backdrops as we will code for asking questions in the backdrop. 

We will create a loop of questions that iterate itself until any one of them wins. 

To repeat in such conditions we will use the Repeat Until block from the control option with = and or operator from the operators option in the block palette. Start adding blocks after When clicked block from events

  • Then, we will store the random numbers in each iteration using the random pick block from operators option with a set block from Variables options in the block palette.  
  • Finally to ask the question we will use the Ask block from the Sensing option with the join block to combine the numbers with operators as string values to display the question. 
  • Lastly, we will add if condition block from the Control option in which we will check the answer with the Answer block from sensing. 

So, here we will ask the question for addition and if the answer is correct we will broadcast a message cat else we will broadcast Dog for a wrong answer using a broadcast block from the Events option. 

Also, add a wait block to give a couple of seconds after each question.  

  • Your code must look like the one in the image below:
Math Games In Scratch
  • Now, click on cat sprite to code for a cat as we have finished the coding for asking questions. 
  • We will make a cat move 20 steps using move block from Motion if the broadcasted message is a cat.  

In addition, we will set the cat wins variable to 0 and make it return to the starting position every time the game is launched.

Finally, we will check to see if it will cross the finish line and set the cat wins variable to 1 to end the game if it does. 

Refer to the code in the image below.

Math Games In Scratch
  • For Dog, we will make it move 20 steps using move block from Motion if the broadcasted message is Dog.  

In addition, we will set the dog wins variable to 0 at the start of the game and make it return to the starting position every time the game begins. 

Finally, if it crosses the finish line, we set the dog wins variable to 1 to end the game as the dog wins. 

Refer to the code in the image below.

Math Games In Scratch
  • Now, click on the green flag to check if your basic Math game asks questions like the one shown in the image below.
Math Games In Scratch

Note: For more fun, I’ve included one sound block for each of the sprites.

Congrats you made it. 

Conclusion

Now that you’ve learned the fundamental method for writing math problems in Scratch, why not put your math acumen to the test and attempt to incorporate more operators to make this a more challenging math game?

Try to add as many operators from the Operators selections, such as Multiplication, Division, and many more, by giving two seconds after each question.

For an example of how I added more operators to produce more math problems to make the game more challenging, see the graphic below.

Learn Scratch at BrightChamps with its specially designed curriculum that makes learning programming easy for students in Grade 1-12.

BrightChamps also teaches a variety of other programs that help kids build a foundation in computer programming for kids through activities, interactive lessons, and other means.

Team BrightChamps

We are an army of educators and passionate learners from BrightChamps family, committed to providing free learning resources to kids, parents & students. Learn from Us

Reach Us

Categories

General Sidebar Widget Coding

Get a Talent Discovery Certificate after trial class

100% Risk-Free. No Credit Card Required

Related Articles

Trending Articles