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.

 

NOTE: You can use any version of Scratch.

 

Complete these steps ..

 

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

 

 

2. Delete the cat sprite, then 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 this code/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 code/script to the stage ..

 

 

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

Add this code/script to the stage ..

 

 

7. Next, we need to paint a tile. 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.

 

When you are done, re-name the tile sprite "tile 1".

 

 

8. Use the File menu to save your game. Name it "Piano tiles v1" ..

 

 

9. Now we need to add the code/script 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 code/script first ..

 

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

Add a "wait" code/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" code/script block ..

 

Step d) Next we want the tile to change to a random colour.

Add a "set color effect" code/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 ..

 

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.

 

 

10. Use the File menu to 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 code/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 code/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 the File menu to save your game.

 

 

14. 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.

 

 

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

Paint (new sprite) a single black dot with the smallest paint brush, like this ..

 

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

 

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. Use the File menu to save your game.

 

 

16. Well done. You've finished. Can you make this game better?