Scratch exercise 53

Combining numbers

It this exercise you will create a combination "lock", which allows you to select three numbers individually, and then use their combined value to control a character's (the cat) movements.


1. Create a new Scratch game .. File>New ..


2. Select the cat sprite underneath the stage and rename it "Cat". Click the button to make him face left-right only and add this script ..


3. Import this spite .. arrow and name it "1+".


4. Duplicate and rotate "1+" and re-name it "1-".


5. Duplicate, re-name and re-colour "1+" and "1-" until you have these sprites ..

Note: Re-colouring them will help you identify them on the stage.


6. Create four variables ("for all sprites") named ..


7. Right-click the variables on the stage, select "large readout".


8. Save your game. Name it "Combining numbers".


9. Add these scripts to the "1+" arrow sprite ..


10. Add these scripts to the "1-" arrow sprite ..


11. Do this for the the "2+", "2-", "3+" and "3-" arrow sprites, making sure you select the correct variables for each.


12. Arrange your variables and arrows on the screen like this ..


12. Add this script to the cat sprite ..


13. Press the "B" key to start your game and click on the arrows to test them, and to ensure the combined number is working correctly.


14. Press the "E" key to stop your game.


15. Add the final script to the cat sprite ..


16. Save your game.


17. Well done. You've finished. Can you use these techniques in a game idea of your own?