Scratch game making tutorial 150

Attack the block

In this tutorial you will create a 10 level game in which the player must move a block from the left side of the stage to the right to complete a level.

 

 

Complete these steps ..

 

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

 

 

2. Delete the cat sprite and then download, save and import ("choose new sprite from file") the following sprites ..

 

 

3. Select the stage and paint in black, then add the following scripts ..

 

 

4. The "How to play" sprite will show when the game begins. Add these scripts to it ..

 

 

5. The "Epic fail" sprite will show if all the players lives are lost before they complete level 10. Add these scripts to it ..

 

 

6. The "Success" sprite will show if the player completes level 10. Add these scripts to it ..

 

 

7. Use "File>Save as" to name and save your game. Name it "Attack the block" ..

 

 

8. The game requires 3 variables. Select the Player sprite and create them now ..

 

 

The player needs to be able to see the Lives and Level variable displays on the stage so leave these visible ..

 

The spacer variable will be used to control the spacing between the blocks.

 

 

9. Click the Costumes tab for the Player sprite and you will see that there are 14 costumes. Note that there are ..

 

Before each level begins, costumes 1 to 13 are used to create a grid of blocks using the "stamp" script block. As the game draws the grid of blocks it will pick random costumes.

You need to know this..

Level 1 selects random costume/blocks from 1 to 13, therefore there is a high chance of green costume/blocks being stamped.

Level 2 chooses costume/blocks from 2 to 13, Level 5 chooses costume/blocks between 5 and 13. Level 10 is the hardest because it chooses costumes between 10 and 13 and there will be a high chance of lots of Red costume/blocks.

 

IMPORTANT NOTE: There is an error in this tutorial. To fix it ..

.. whenever you are asked to set Y to 154, instead set it to 155

 

10. The first Player sprite script prepares it for the game. This script runs whilst the "How to play" sprite is showing. Add the following script to the Player sprite ..

 

The values in the "go to X: Y:", "set size to", and "set Spacer to" script blocks are critical to achieving the correct spacing of the grid of blocks. Check them carefully.

 

 

11. Switch the the Player Sounds tab and import a simple short sound ..

 

Now add a simple script to play a warning sound whenever the Player sprite touches the edge of the stage or a red block ..

 

 

12. The next Player sprite script draws the grid of blocks before each level begins.

Notice how this script uses the "Level" variable to determine the range of costumes to be chosen for stamping. As the difficulty level increases less green costumes are available to be chosen thus increasing the chance of more black gaps and red blocks.

Add the script ..

 

Press the "B" key on your keyboard to test your game. You should see the "How to play" sprite and then when you click it the block of grids should be drawn after which the Yellow Player costume/block should appear at the top left.

 

When you are ready press the "E" key to end your game, and then use "File>Save" to re-save it ..

 

 

13. The next Player sprite script enables movement using the arrow keys. Add it now ..

 

Go full screen and then press the "B" key on your keyboard to test your game. You should be able to move the Green player sprite around the grid.

When you are ready exit full-screen, and then press the "E" key to end your game.

 

 

14. The next Player sprite script is long. It contains a "forever" script block and 6 "if" script blocks. Follow the instructions for adding each script block.

After you have added the "when I receive begin game" and "forever" script blocks start by completing the first "if" script. This makes the Player fall when there is a black/gap ..

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

When you are ready press the "E" key to end your game and continue working on it.

 

 

15. Next add the "if" script which causes the Player to lose a life and return to the start if it touches the edge of the stage ..

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

When you are ready press the "E" key to end your game and continue working on it.

 

 

16. Use "File>Save" to re-save the game ..

 

 

17. Next add the "if" script which causes the Player to lose a life if it touches a red block ..

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

When you are ready press the "E" key to end your game and continue working on it.

 

 

18. When the Player successfully reaches the right most column of blocks a new grid is drawn and the Level changes. Add the next "if" script to achieve this ..

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

When you are ready press the "E" key to end your game and continue working on it.

 

 

19. Use "File>Save" to re-save the game ..

 

 

20. Next add the "if" script which ends the game if the Player completes Level 10 ..

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

When you are ready press the "E" key to end your game and continue working on it.

 

 

21. Next add the "if" script which ends the game if the Player runs out of Lives before completing a Level ..

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

When you are ready press the "E" key to end your game and continue working on it.

 

 

22. Use "File>Save" to re-save the game ..

 

 

23. Well done, you've finished making the game! Can you complete it? Can you improve it with your own ideas?