Lesson What you will learn: how to edit the stage using the Paint Editor facility within Scratch how to make the sprite react to different colours how to import a new sprite from the ones available within Scratch how to create new costumes for the sprite how to create and use variables how to set the sprite to start in a certain position You will practise: animating the sprite creating random movement for the sprite Contents Exercise 1 Making the Sprite Interact with the Background... 2 Exercise 2 Importing a New Sprite and New Costumes... 5 Exercise 3 Making the Countdown... 8 Exercise 4 Scoring the Game... 9 Exercise 5 Choosing Start Positions for the Sprites... 10 Exercise 6 Finishing the Game... 10 Introduction to Scratch Programming (2 nd Edition) Page 1 of 10 ZigZag Education, 2013
Exercise 1 Making the Sprite Interact with the Background In this section, you will edit the background of the stage. 1. Double-click the stage symbol to the left of the sprite area. 2. Select the Backgrounds tab. 3. Click on Edit. Introduction to Scratch Programming (2 nd Edition) Page 2 of 10 ZigZag Education, 2013
4. Working in Paint Editor, draw a simple maze (hint: students often make this too complicated keep it simple). 5. Click OK in the Paint Editor to return to the main programming view. 6. Using the Shrink sprite option, resize the sprite so that it can fit in all parts of the maze. Introduction to Scratch Programming (2 nd Edition) Page 3 of 10 ZigZag Education, 2013
We want the sprite to interact with the maze we have drawn and so we need to make a script that will make the sprite bounce off the maze. 7. Double-click the sprite at the bottom of the screen (not the sprite on the stage). 8. Choose the Switch to small stage option in order to make room for some more scripts. 9. Create the script as shown: a) Select if from the Control instruction set. b) Select touching colour from the Sensing instruction set (use pipette to set colour to black). c) Select move -15 steps from the Motion instruction set. 10. Combine this script with the list of others that are to do with motion. 11. Click the green flag again. 12. Test the game by trying to drive the sprite over the black areas (it should bounce off). Introduction to Scratch Programming (2 nd Edition) Page 4 of 10 ZigZag Education, 2013
Exercise 2 Importing a New Sprite and New Costumes 1. Start a new Scratch project and delete the cat. 2. Click the centre button below the stage. This allows you to import a new sprite onto the stage. 3. Browse the Things folder and select beachball1. The ball comes with only one costume and we need four to make it seem to roll about. 4. With the ball sprite selected, click the Costumes tab and click Copy. Clicking copy creates a new costume. Introduction to Scratch Programming (2 nd Edition) Page 5 of 10 ZigZag Education, 2013
5. Working with the copied costume (the bottom one), click on Edit to go into the Paint Editor. 6. Rotate the costume by clicking the Rotate clock-wise button three times. Click OK. 7. Repeat this process until you have created four costumes for different rotations of the ball. Introduction to Scratch Programming (2 nd Edition) Page 6 of 10 ZigZag Education, 2013
8. With the ball sprite clicked, create this script (animation of the ball rotation). 9. With the ball sprite clicked, create this script. (This will give automatic movement of the ball round the screen at the same time as avoiding the maze, the edge and the cat.) This section creates the automatic movement of the ball. This section causes the ball to bounce off the maze (or anything that is black). This section causes the ball to bounce off the cat. This section causes the ball to bounce off the sides. Introduction to Scratch Programming (2 nd Edition) Page 7 of 10 ZigZag Education, 2013
Exercise 3 Making the Countdown 1. Click the red Variables tab and click Make a variable. These options will appear. 2. Create the script shown below. There are three parts to this: Firstly, the countdown is set to 20. Secondly, the countdown is reduced by one every second. Thirdly, when the countdown reaches zero, the action stops. Introduction to Scratch Programming (2 nd Edition) Page 8 of 10 ZigZag Education, 2013
Exercise 4 Scoring the Game 1. Select Make a variable and call it Score. 2. Create this script for Sprite1 (the cat). Every time the cat touches the ball, the score will go up by one. The cat should bounce off the ball straight away (otherwise the score would just go up and up). Introduction to Scratch Programming (2 nd Edition) Page 9 of 10 ZigZag Education, 2013
Exercise 5 Choosing Start Positions for the Sprites 1. Click on Sprite1. 2. Position Sprite1 in your chosen start position. 3. From the movement instruction set, drag the go to instruction and place it as shown. 4. (The sprite will remember this position in future every time the game starts.) 5. Repeat for the other sprite. Exercise 6 Finishing the Game 1. Position the countdown and score displays inside the maze so that they do not get in the way of the ball or the cat. You have made a game! Introduction to Scratch Programming (2 nd Edition) Page 10 of 10 ZigZag Education, 2013