Mathematics Scratch Game
Hard
90 mins
280 points
What you need:
  • Computer/laptop

Match Simulator

In this lesson we will create an app that simulates the events and goals of a football match. Players will create their own 5 a side teams and play a simulated match. 

1 - Create a new Scratch project

Create a new Scratch project and delete the cat sprite.

https://scratch.mit.edu

2 - Create the lists

In the Data palette, create 3 new lists by clicking the 'Make a List' button.

  1. 'Team 1' this will store the names of the players on Team 1
  2. 'Team 2' this will store the names of the players on Team 2
  3. 'Events' this will store the events that can happen in the match like a player scoring or someone missing.

3 - Create the variables

We will need some variables to store values to help us run the game. Variables are things that we use to store some information such as the top score of a game or what level you're on.

In the Data palette, create 5 new variables by clicking the 'Make a Variable' button.

  1. 'team' this will store which team the next event will be for
  2. 'player' this will store which player from the team
  3. 'minute' this will store the current minute of the match
  4. 'score team 1' this will store the score for Team 1
  5. 'score team 2' this will store the score for Team 2

4 - Add a referee sprite

We're going to use a referee sprite to call out the events that happen in the match. Add the Referee sprite from the sprite library and then drag the referee into the middle of the stage area.


5 - Hide the variables and lists

When you add a variable or a list, a box appears in the stage area that shows you what the value of it is. This can clutter up the stage area so we're going to set some of them to hide and arrange the ones we want to keep visible.

Add the following code to the Referee sprite.

when green flag clicked hide variable [team v] hide variable [player v] hide list [events v] switch costume to [referee-b v]// start off with this costume

Click the green flag to run your code and they will disappear. Next we want to position the remaining boxes like in the picture included with this step, by dragging them into position


Join our club 😃

To view the remaining 11 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