


To make the variables a bit nicer to look at, you can right click on the variable (as shown on the stage), and select the “large readout” option. Set up the basic version of the game by creating the following scripts for your sprites: You can tell that you have created a variable for a single sprite if, prior to the name of the variable, Scratch displays the name of the sprite followed by a colon: If you create a variable for this sprite only, no other sprites are able to see what the value of that variable is (even if you drag the variable onto another sprite). When creating your variables, you should leave the For all sprites button selected (instead of switching it to For this sprite only) unless you have a very good reason for declaring the variable to only be accessible by the current sprite. Go to the Data tab to create these, making sure you provide descriptive names for the variables. We need to create two variables, one to hold the number chosen by the dinosaur and one to hold the number chosen by the reindeer.

This would obviously be a terrible game to play with humans, but it will serve nicely to illustrate possible timing issues. The duck sprite will then determine which sprite is the winner (by checking which number is larger), and announce the winner. First, create three sprites and position them on the stage as follows:įor our game, we will the dinosaur and reindeer sprites each choose a random number from 1 to 100. To demonstrate this problem, we will create a very simple “game” that intentionally exposes this problem. If the response of one sprite depends on another sprite already taking an action, this can cause difficult to find problems in your project. Although you can certainly respond to an event with many different sprites, there is no guarantee as to the order in which those responses will occur. This can happen when you respond to one event with multiple sprites. When you begin creating more complicated projects in Scratch, it is possible to run into problems that we will call timing issues.
