You are on page 1of 29

02/06/2022, 08:40 Drum star

Projects

Drum star
Make a clicker game where you earn beats to play
new drums and bigger venues

Step 1 Introduction

Make a clicker game where you earn beats to play new drums at bigger venues.
You will:
Use variables to store and change numbers and text (words)
ask a question and use the answer to customise the game
Use if...else blocks to make decisions

There are lots of clicker games where you have to click to make progress and buy upgrades that help you go
faster. Have you ever played a clicker game? There are also idle games that keep going even when you’re not
playing them. These games are fun as long as you don’t spend too much time playing them!

https://projects.raspberrypi.org/en/projects/drum-star/print 1/29
02/06/2022, 08:40 Drum star

Step 2 Set the stage

In this step, you will set the stage for your first gig and
choose a rock star name.

Open the Drum star starter project (https://scratch.mit.edu/projects/535783147/editor). Scratch


will open in another browser tab.

Working offline
For information about how to set up Scratch for offline use, visit our ‘Getting started with Scratch’
guide (https://projects.raspberrypi.org/en/projects/getting-started-scratch/1).

Musicians called DIY artists start recording music from their bedrooms. They produce their own songs by
themselves then release them online for everyone to hear.

The game starts in a bedroom like a DIY artist.

Click Choose a Backdrop and search for bedroom.

Choose: Select a bedroom and add it to your project. We chose Bedroom 3.

https://projects.raspberrypi.org/en/projects/drum-star/print 2/29
02/06/2022, 08:40 Drum star

In Scratch, you can add code to the Stage.


Click on your bedroom backdrop from the Stage pane and add this code:

when clicked

switch backdrop to Bedroom 3 your backdrop name

Every musician needs to choose a rock star name.


A variable is a way of storing numbers and/or text. Your rockstar name will be stored in a variable so it can be
used at any time.

From the Variables blocks menu, click the Make a Variable button.

Call your new variable name:

Notice: The new name variable appears on the Stage and can now be used in the Variable blocks.

https://projects.raspberrypi.org/en/projects/drum-star/print 3/29
02/06/2022, 08:40 Drum star

At the start of the project, your rockstar name is unknown.


Add a block to set name to ???:

when clicked

switch backdrop to Bedroom 3 your backdrop name

set name to ??? your variable

You can ask a question in Scratch, then use a variable to store the answer.

Click on the Sensing blocks menu and add an ask block to your code:

when clicked

switch backdrop to Bedroom 3 your backdrop name

set name to ??? your variable

ask What's your rock star name? and wait your question

https://projects.raspberrypi.org/en/projects/drum-star/print 4/29
02/06/2022, 08:40 Drum star

Set the name variable to the answer:

when clicked

switch backdrop to Bedroom 3 your backdrop name

set name to ??? your variable

ask What's your rock star name? and wait your question

set name to answer

Change the way your variable looks on the Stage.

Right-click on the variable on the Stage and choose large readout:

Drag your variable to position it in top-right of the Stage:

Test: Run your project to make sure the variable starts as ??? then updates to your answer.

https://projects.raspberrypi.org/en/projects/drum-star/print 5/29
02/06/2022, 08:40 Drum star

Now that you have tested that the variable changes to the answer, you can drag the last 2 blocks of
code away from the rest of the script. This means you don’t have to type an answer every time you test
your project:

when clicked

switch backdrop to Bedroom 3 your backdrop name

set name to ??? your variable

ask What's your rock star name? and wait your question

set name to answer

Save your project

https://projects.raspberrypi.org/en/projects/drum-star/print 6/29
02/06/2022, 08:40 Drum star

Step 3 Starter drum

You will add a cymbal sprite that you can click to earn beats
and play a sound.

Click Choose a Sprite and search cymbal. Add the Drum-cymbal sprite to your project.

Position your cymbal on the Stage:

https://projects.raspberrypi.org/en/projects/drum-star/print 7/29
02/06/2022, 08:40 Drum star

Add the Music extension:

How to add the Music extension


To use the Music blocks in Scratch, you need to add the Music extension.

Click on the Add extension button in the bottom left-hand corner.

Click on the Music extension to add it.

The Music section then appears at the bottom of the blocks menu.

https://projects.raspberrypi.org/en/projects/drum-star/print 8/29
02/06/2022, 08:40 Drum star

Add a script to make the cymbal switch costume and play a drum sound:

when this sprite clicked

switch costume to drum-cymbal-b hit costume

play drum (5) Open High-Hat for 0.25 beats drum sound

switch costume to drum-cymbal-a not hit costume

Test: Test your cymbal by clicking on it. Make sure you hear a sound and see the costume change.

The Drum-cymbal sprite will earn you one beat each time you click it.

https://projects.raspberrypi.org/en/projects/drum-star/print 9/29
02/06/2022, 08:40 Drum star

Create a variable called beats:

Add a block to change beats by 1 when the Drum-cymbal sprite is clicked:

when this sprite clicked

change beats by 1

switch costume to drum-cymbal-b

play drum (5) Open High-Hat for 0.25 beats

switch costume to drum-cymbal-a

Test: Test the Drum-cymbal by clicking on it and watch the beats increase.

The beats variable needs to start at 0 beats when you start a new game.

https://projects.raspberrypi.org/en/projects/drum-star/print 10/29
02/06/2022, 08:40 Drum star

Click on the Stage pane and then the Code tab to add code to the Stage.
Add a block to set beats to 0:

when clicked

switch backdrop to Bedroom 3

set name to ???

set beats to 0

Test: Click the green flag and make sure your beats variable starts at 0.

Save your project

https://projects.raspberrypi.org/en/projects/drum-star/print 11/29
02/06/2022, 08:40 Drum star

Step 4 First upgrade

You will add your first upgrade. The Get snare button will
show at the start, so the player knows which drum they are
working towards.

Add the Drum-snare sprite to your project and position it on the Stage:

Drag the when this sprite clicked script from the Drum-cymbal sprite to the Drum-snare
sprite.

Copy code from one sprite to another

You can copy code from one sprite to another sprite in the Sprite list:

Both sprites will have the code blocks that you have copied. If you are moving the code from one
sprite to the other, you can delete the code from the first sprite after you have copied it to the other
sprite.

https://projects.raspberrypi.org/en/projects/drum-star/print 12/29
02/06/2022, 08:40 Drum star

Change the costumes and the drum sound.


Change the number of beats earned to 2:

when this sprite clicked

change beats by 2 2 beats per click

switch costume to drum-snare-b hit costume

play drum (1) Snare Drum for 0.25 beats drum sound

switch costume to drum-snare-a not hit costume

Test: Try out your project. Make sure that you earn 2 beats when you click on the snare drum.

Upgrades are not available when you start the project. They have to be earned with beats.

Add a script to hide this drum sprite at the start of the project:

when clicked

hide

A button will show which drum is the next upgrade option and how many beats it will cost.

https://projects.raspberrypi.org/en/projects/drum-star/print 13/29
02/06/2022, 08:40 Drum star

Duplicate the Get sprite:

Change the visibility to Show and change its name to Get snare. Position it in the bottom-right corner
of the Stage:

Click on the Drum-snare sprite and go to the Costumes tab. Use the Select (arrow) tool to highlight the
not hit costume of your drum. Click on the Group icon then the Copy icon:

https://projects.raspberrypi.org/en/projects/drum-star/print 14/29
02/06/2022, 08:40 Drum star

Click on your Get snare sprite and Paste the snare costume. You might need to resize and position it to
fit your button:

Click on the Code tab and add a script to show the Get snare sprite at the start of the project:

when clicked

show

The upgrade can only be bought if the user has 10 or more beats. In Grow a dragonfly (https://projects.raspberr
ypi.org/en/projects/grow-a-dragonfly), you learned about making decisions with if blocks.

An if ... else block is used to make a decision and will do different things if a condition is true or false.

We use if … else all the time to make decisions. When you wake up, you check if it is morning. You get up, or
else you go back to sleep. Can you think of any if ... else decisions you make?

https://projects.raspberrypi.org/en/projects/drum-star/print 15/29
02/06/2022, 08:40 Drum star

Add this code to get the upgrade if the player has enough beats, or say Not enough beats! if they
are not able to upgrade:

when this sprite clicked

if beats > 9 then if 10 or more beats

hide

change beats by -10 take away the cost of upgrade

else

say Not enough beats! for 2 seconds

Let other sprites and the Stage know that the snare upgrade has been bought.

https://projects.raspberrypi.org/en/projects/drum-star/print 16/29
02/06/2022, 08:40 Drum star

Add a broadcast block to send a new snare message:

when this sprite clicked

if beats > 9 then if 10 or more beats

hide

change beats by -10 take away the cost of upgrade

broadcast snare your drum name

else

say Not enough beats! for 2 seconds

Click on the Drum-snare sprite. Add this script:

when I receive snare

show

When you upgrade your equipment, you will be able to play at bigger venues.

https://projects.raspberrypi.org/en/projects/drum-star/print 17/29
02/06/2022, 08:40 Drum star

Add another backdrop. We chose Chalkboard to play our second gig at school.
Add code to the Stage to switch backdrop when the upgrade message is received:

when I receive snare

switch backdrop to Chalkboard

Tip: Choose a venue that’s a small step up from the bedroom. You want to save bigger venues for later.

Test: Run your project. Try and buy the snare upgrade before you have enough beats.
When you buy the upgrade check: the snare appears, the button disappears, the venue changes and the
beats go down by 10.

Save your project

https://projects.raspberrypi.org/en/projects/drum-star/print 18/29
02/06/2022, 08:40 Drum star

Step 5 Second upgrade

Your drum skills are improving. Time for a second upgrade!


In this step, you will choose which drum to add.

Duplicate the Drum-snare sprite:

The Drum Costumes sprite has lots of drum costumes for you to choose from.

Click on the Drum Costumes sprite and select the Costumes tab.
Choose: a drum for the next upgrade. We chose Conga.

Drag the ‘hit’ and ‘not hit’ costumes of your chosen drum to your new Drum-snare2 sprite:

https://projects.raspberrypi.org/en/projects/drum-star/print 19/29
02/06/2022, 08:40 Drum star

Name your drum to match the costumes you chose.

Click on the Code tab. Change the code to use the correct costumes and choose a sound for your new
drum.

Change the number of beats you earn by clicking the new drum to 5:

when this sprite clicked

change beats by 5 5 beats per click

switch costume to your hit costume

play drum for 0.25 beats your drum sound

switch costume to your not hit costume

Drag your new drum into position on the Stage:

https://projects.raspberrypi.org/en/projects/drum-star/print 20/29
02/06/2022, 08:40 Drum star

Next, you need a button so that players can upgrade to this new drum.

Duplicate the Get snare sprite.


Position it in the bottom-right corner of the Stage. Change its name to Get and then the name of your
new drum:

Delete the snare drum from the button costume. Copy and paste the ‘not hit’ costume for your new
drum to the button costume.
Click on the Text tool and change the number to 30 to show the cost of the new drum.

Your button should look like this:

This button should hide at the start, then show when the player upgrades to the snare drum, so they know which
drum they are working towards.

https://projects.raspberrypi.org/en/projects/drum-star/print 21/29
02/06/2022, 08:40 Drum star

when clicked

show

hide

Tip: To delete a block, drag it to the Blocks menu, or right-click and choose Delete Block. On a
computer, you can also click on a block and then tap Delete to remove a block.

Add a when I recieve script that your new drum button will show as the next upgrade when the
player gets the Drum-snare drum:

when I receive snare appear when previous drum is bought

show show button for next available drum

https://projects.raspberrypi.org/en/projects/drum-star/print 22/29
02/06/2022, 08:40 Drum star

Change the number of beats needed to buy this drum, and the number of beats that are removed, when
the player gets this drum.
Also change the message that is broadcast when the player gets the new drum. Create a new
message with the name of your new drum:

when this sprite clicked

if beats > 29 then change to 29

hide

change beats by -30 change to 30

broadcast conga change to your drum name

else

say Not enough beats! for 2 seconds

Change the when I receive snare script to broadcast the name of your new drum. The drum will
show when the player upgrades to the new drum:

when I receive conga change to your drum name

show

https://projects.raspberrypi.org/en/projects/drum-star/print 23/29
02/06/2022, 08:40 Drum star

Add the Party backdrop.


Add a script to the Stage to switch the backdrop when the player upgrades to the new drum:

when I receive conga change to your drum name

switch backdrop to Party

Test: Click the green flag to start the game and test that you can earn enough beats to get your new
drum.
What happens if you click the button before you have earned enough beats?

Save your project

https://projects.raspberrypi.org/en/projects/drum-star/print 24/29
02/06/2022, 08:40 Drum star

Step 6 Play and customise

It’s time to make your game work just the way that you want
it to.

Play your game and earn beats.


Watch the beats variable change and make sure you understand how beats increase when you click the
drums and decrease when you get a new drum.
Are you happy with how many beats you earn for each drum? You can change this if you like.

Are you happy with how many beats it costs to get a new drum?
Tip: Test your project regularly so you can find and fix any bugs.

If you separated the ask block on the Stage, put it back and set your rock star name.

Notice that the name displayed on the Stage changes.

Save your project

https://projects.raspberrypi.org/en/projects/drum-star/print 25/29
02/06/2022, 08:40 Drum star

Upgrade your project


Upgrade your project with more drums and more backdrops
as you play more amazing venues.

There are lots more drum costumes to choose from to add more upgrades to your project.

To add another drum to upgrade to, look back at the earlier steps of the project.
For the drum, you will need to:

Duplicate the previous drum sprite and add two costumes.

Change the costume and sound used in the when this sprite clicked script.

Change the number of beats earned in the when this sprite clicked script.

Change the message that makes the drum show to a message for the new drum.

For the button, you will need to:

Duplicate the previous Get sprite.

Change the message that makes the button appear to the message broadcast by the previous drum.

Change the costume including the cost of the new drum.

Change the number of beats you must have to get this drum in the if condition. Change the negative
number of beats you change by when you get this drum. Change the message that gets broadcast
to the name of the new drum.

For the venue, you will need to:

Add a new backdrop.

https://projects.raspberrypi.org/en/projects/drum-star/print 26/29
02/06/2022, 08:40 Drum star

Add a script to the Stage to switch backdrop to the new backdrop when the message for this drum
is receieved.

You might find that your drums need to be in a new position on a different backdrop.

Add script starting with when backdrop changes to to each drum sprite with a go to block to
make them change position.
You will also need to set their starting position when flag clicked.

Tidy: If you have time, then it’s a good idea to make sure the sprites in the sprite list are in a sensible
order, starting with the drums in their upgrade order and then the buttons in order.

Debug: First make sure you really understand when the drums and buttons should show and how the
beats variable should change. It’s much easier to debug a project if you are clear on what it is supposed
to do.

My drum doesn't show/hide correctly


Unless it is the first drum, your drum should have a when flag clicked script to hide. And it
should have a when I receive this drum script to show.

Check that the Get button for this drum broadcasts the same message.

My Get button doesn't show/hide correctly


Unless the button is for the very first drum, then it should hide when flag clicked. And it should
show when I receieve the message for the previous drum. The Get button should show to let
the player know about the next upgrade they are working towards.

I can buy a drum when I don't have enough beats


Check that you have changed the number of beats needed when this sprite clicked in the
script for the Get button for the drum.

The number of beats doesn't change correctly when I get a new drum
Check that you have changed beats by a negative number when this sprite clicked in the
script for the Get button for the drum.
Make sure this matches the number on the drum button costume.

Completed project

https://projects.raspberrypi.org/en/projects/drum-star/print 27/29
02/06/2022, 08:40 Drum star

You can view the completed project here (https://scratch.mit.edu/projects/522323676/).


Tip: If you get really muddled then it’s fine to delete the new drum and its button, and start again. Sometimes it is
hard to spot a bug.

Save your project

https://projects.raspberrypi.org/en/projects/drum-star/print 28/29
02/06/2022, 08:40 Drum star

What next?
If you are following the More Scratch (https://projects.raspberrypi.org/en/raspberrypi/more-scratch)
pathway, you can move on to the Next customer please! (https://projects.raspberrypi.org/en/projects/next-
customer-please) project, where you will make a shop where customers can buy items and check out.

If you want to have more fun exploring Scratch, then you could try out any of these projects (https://projects.ra
spberrypi.org/en/projects?software%5B%5D=scratch&curriculum%5B%5D=%201).

Published by Raspberry Pi Foundation (https://www.raspberrypi.org) under a Creative Commons


license (https://creativecommons.org/licenses/by-sa/4.0/).
View project & license on GitHub (https://github.com/RaspberryPiLearning/drum-star)

https://projects.raspberrypi.org/en/projects/drum-star/print 29/29

You might also like