Scratch exercise 153

Auto grid creator

In this exercise you will create algorithms that draw a precise grid on the stage.



Complete these steps ..


1. Open Scratch, OR create a new game (from the top menu choose "File>New").



2. Right-click on the Cat sprite under the stage to delete it.



3. Select the stage and add these scripts ..




4. Download, save and then use the "Choose new sprite from file" button under the stage to import these sprites ..



5. Create the following variables ("for all sprites") ..


Hide the "grid spacing" variable, and then drag the remaining 2 variable displays on top of each other at the top middle edge of the stage. After you've positioned them you can then hide them too.



6. Use "File>Save as" to name and save your game. Name it "Auto grid creator" ..



7. Select the Vertical line sprite and add this script (you don't need to add the comments but you should read them to understand what each part of the script does) ..


Press the "B" key on your keyboard to test your game.



8. Use "File>Save" to re-save your game ..



9. Now add the scripts for the Horizontal grid line, these lines are drawn after the vertical ones ..


Press the "B" key on your keyboard to test your game.



10. Use "File>Save" to re-save your game ..



11. Well done, you've finished the exercise.