Mathematics Scratch
Advanced
60 mins
130 points
What you need:

Adding Game

How many addition sums can you get right in 30 seconds!?

1 - Create a new Scratch project

In this game players will try and answer correctly as many addition sums as they can in 30 seconds.

Go to the Scratch website at scratch.mit.edu and create a new Scratch project. You can delete the cat sprite.

2 - Add the Giga sprite

Add the Giga sprite from the sprite library.

This sprite will ask the questions.


3 - Create some variables

We will need 4 different variables to store some numbers that we need in the game.

Create the following 4 variables:

  • number1 - this will store the first number in the sum
  • number2 - this will store the second number in the sum
  • max number - this will store the maximum number that can be used in the sums
  • points - this will store how many sums the player gets right

After you have created the variables, uncheck their checkboxes so that they do not appear in the stage area.


4 - Start the game

Let's set up some things for the start of the game. We will set the 'points' variable to 0, set the 'max number' variable to 10 and start the timer.

Add the following code to the Giga sprite.

when green flag clicked set [points v] to (0) set [max number v] to (10) reset timer

The reset timer block is a Sensing block. The block sets the timer's value back to 0.0 seconds. When this block is used, the project typically also uses the timer block which stores the current value of the timer in seconds. Usually the timer must be reset at the beginning of a project for the timer block to hold the right value.

5 - Ask a sum

To make Giga ask a sum we need to set number1 and number2 to random numbers between 1 and the 'max number'. Then we need to make Giga ask the sum and wait for the answer.

Add the following new code to the Giga sprite, underneath the reset timer block.

when green flag clicked set [points v] to (0) set [max number v] to (10) reset timer // add the new code under here forever set [number1 v] to (pick random (1) to (max number)) set [number2 v] to (pick random (1) to (max number)) ask (join [what's ] (join (number1) (join [ + ] (number2)))) and wait end

We put this new code in a forever block because we want Giga to keep asking the player sums over and over until the 30 seconds is up.


Join our club 😃

To view the remaining 2 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.

Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more