Scratch game making tutorial 124

Piano tiles

In this tutorial you will make a game that lets you play a tune by clicking on tiles as they float up the stage! The tiles move faster the longer you play.

 

Complete these steps ..

 

 

1. Create a new game, then right-click to delete the cat sprite.

 

 

2. Select the stage, click on its "Backgrounds" tab, then click the edit button and paint the stage black.

 

 

3. Select the stage's "Scripts" tab and add these scripts ..

 

 

4. We need three variables for this game. Create the following variables ("for all sprites") ..

We don't need to see them on the stage so un-tick them.

The "tiles clicked" variable will record how many tiles the player has clicked on.

The "tiles seen" variable will record how many tiles have appeared and floated upwards.

The "tiles speed" variable will control the speed of the tiles. They will get faster as the games goes on.

 

 

5. Now add this script to the stage ..

 

 

6. We need to add the script that controls the speed of the tiles and make it increase every 10 seconds. Add this script to the stage ..

 

 

7. Next, we need to paint a tile. Click the "paint new sprite" button under the stage ..

.. and paint a red tile like this ..

Tip: You can use the square tool and hold down the shift key on your keyboard as you drag to get a perfect square.

 

Re-name the tile "tile 1".

 

 

8. Use "File>Save as" to save your game. Name it "Piano tiles".

 

 

9. Now we need to add the scripts to "tile 1".

Let's build the first script ONE STEP AT A TIME.

 

Step a) When the game starts we want the tile to be hidden. Add this script first ..

 

Step b) Next we want the tile to wait for a random time before appearing. Add a "wait" script block ..

 

Step c) Next we want the tile to go to a random location along the bottom edge of the stage. Add a "go to" script block ..

 

Step d) Next we want the tile to change to a random colour. Add a "set color effect" script block ..

 

Step e) Next we want to change the "tiles seen" variable by one and then the tile to show ..

 

Step f) Finally, we want the tile to move up the stage until it reaches the top at y position 180 ..

 

 

10. Now, press the "B" key to test your game. The tile should appear and float up the stage. Press "E" to end when you are done.

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

 

 

11. When the tiles are clicked we want the "tiles clicked" variable to change by 1 and a random piano note to sound.

Add this script to "tile 1" ..

Now, put on your headphones, go full-screen, and press the "B" key to test your game. When you click on the tile a piano note should sound. Press "E" to end when you are done.

 

 

12. We want the tile to animate and disappear when it is clicked on. Add this script to "tile 1" ..

 

Press the "B" key to test your game. When you click on the tile a piano note should sound, then it should spin and disappear. Press "E" to end when you are done.

 

 

13. If your tile scripts are working fine use "File>Save" to re-save your game.

Right-click "tile 1" under the stage and duplicate it 3 times so you have 4 tiles. Re-name the duplicates "tile 2", "tile 3", and "tile 4".

 

Now, go full-screen and then press the "B" key to test your game. Test all 4 tiles. Press "E" to end when you are done.

 

 

14. It would be really cool if the game told the player how many tiles had appeared and how many had been successfully clicked on.

Click the "paint new sprite" button under the stage ..

.. and paint a single black dot with the smallest paint brush, like this ..

 

Re-name this new sprite "score" and add this script to it ..

 

 

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

Well done. You've finished. Press the "B" key to test your game. Press "E" to end when you are done.

 

 

16. Can you make this game better?