Projects
Find the bug
Create a game in which you have to find a hidden bug
on each level
Step 1 You will make
Create a game in which you have to find a hidden bug 🐞 on each level. The game will have ‘start’ and ‘end’ screen
backdrops, and a timer ⌚ to show the player how quickly they found the bugs.
You will:
Create levels for your game using next backdrop and when backdrop switches to blocks
Use a forever loop to keep running code blocks
Use the timer variable to let the player know how quickly they found the bugs
More than 2.5 billion people play video games every year. Just think how many people are involved in creating
those games. Would you like a job designing, coding, or testing games for other people to play?
Step 2 Start screen
Give your game a ‘start’ screen.
Open the starter project
Open the Find the bug starter project (https://scratch.mit.edu/projects/582214723/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).
Add a Backdrop
Add the Chalkboard backdrop from the Indoors category.
The Stage has a Backdrops tab instead of a Costumes tab. This is where you can create images for the Stage.
Click on the Stage pane.
Edit the Backdrop
Click on the Backdrops tab to open the Paint editor.
Select backdrop1 and click on the Delete icon to remove the backdrop1 backdrop from your project.
You will not need the backdrop1 backdrop in this project.
The Chalkboard backdrop will now be highlighted.
Click on Convert to Vector. Now, you will be able to add text that you can move around.
Use the Text tool to add the text Find the bug to the chalkboard:
We used the Marker font in white, but choose the font and colour that you want to use.
Tip: Switch to the Select (Arrow) tool to move your text around. To change the size of the text, grab the
corner of the text and drag it.
Rename the Backdrop
Change the name of the backdrop to start, because you will need to select it later in the project.
Tip: If you use names that make sense, it will be easier to understand your project, especially when you
come back to a project later.
Add the Bug Sprite
Delete the Scratch Cat sprite.
Click on Choose a Sprite and type bug in the search box.
Choose: Choose a bug, which players will need to find in your game.
Tip: Give your project a name. You might like to include the name of the bug that you have just chosen.
A mistake in a computer program is called a bug. Finding and removing mistakes in computer programs is
called debugging. Grace Hopper is a famous software engineer. Her team once found a moth in their
computer. Their notes say, “First actual case of bug being found.”
Step 3 First level
Add a new backdrop as the first level in your game, and hide
the bug.
Add another Backdrop
Add the Spotlight backdrop from the Music category.
Resize the bug
Click on the bug sprite in the Sprite list. Add a script to change the size of your bug when the
backdrop switches to Spotlight:
when backdrop switches to Spotlight
set size to 20 % tiny
Click on the code to change the size, then drag your tiny bug to a hiding place.
Add code to position your bug:
when backdrop switches to Spotlight
set size to 20 % tiny
go to x: 13 y: 132 on the disco ball
Choose: You can choose a different size and location, if you prefer.
Move to the next Backdrop
When you play the game and you successfully find the bug, the game will switch to the next backdrop. Also, to
start the game, you will click on the bug on the ‘start’ screen.
The next backdrop block switches to the next backdrop in the order in which the backdrops are listed when you
click on the Backdrops tab for the Stage.
Add a script to your bug sprite to play a Pop sound and switch to the next backdrop when this
sprite is clicked:
when this sprite clicked
play sound Pop until done
next backdrop
Make the game start with the Start Screen
Click on the Stage pane and add this code to the Stage:
when clicked
switch backdrop to start 'start' screen
Test: Click on the green flag to test your project.
You will notice that on the ‘start’ screen, the bug will still have the settings to hide in its hiding place
from the first level (in this example, on the disco ball).
Tip: After the last backdrop in the list, next backdrop will switch back to the first backdrop.
Click on the bug sprite in the Sprite list. Add a script to set the size of the bug when your
backdrop switches to the start screen:
when backdrop switches to start
set size to 100 % full-sized
Change the position of the bug
Try to position the bug on the ‘start’ screen.
Your code will make the backdrop switch when you click on the bug! That is not helpful when you are
trying to position the bug.
To fix the problem, you need to stop the code from running when you click on the bug.
Click on the green flag to return to the ‘start’ screen.
Click on the bug sprite in the Sprite list and drag the blocks away from the when this sprite
clicked block:
Try to position the bug again. Drag the bug onto the chalkboard, below the text:
Add code to make sure that the bug is positioned on the chalkboard every time your backdrop
switches to the start screen:
when backdrop switches to start
set size to 100 % full-sized
go to x: 0 y: 30 on the board
Join the blocks back together so that the code blocks are under the when this sprite clicked
block again:
Test: Click on the green flag to test your project. Click on the bug to move to the next backdrop. The bug
should be big on the ‘start’ screen and small on the ‘Spotlight’ level.
Nothing happens when I click on the bug
Did you forget to join the code back to the when this sprite clicked block?
Step 4 Parrot distraction
To make it harder for players to find and click on the bug,
you will add an annoying parrot to distract them.
Add the Parrot sprite
Add the Parrot sprite.
Animate the Parrot sprite
In the Catch the bus (https://projects.raspberrypi.org/en/projects/catch-the-bus) project, you used a
repeat loop.
You will use a different loop here. A forever loop runs the code blocks inside it again and again. It is the perfect
loop for an annoying parrot that will not stop flying around and getting in the way.
Add code to make the parrot flap around in a distracting way:
when clicked
set rotation style left-right do not go upside down
point in direction 35 number from -180 to 180
forever keep being annoying
move 10 steps the number controls the speed
if on edge, bounce stay on the Stage
next costume flap
change color effect by 5 try 11 or 50
wait 0.25 seconds try 0.1 or 0.5
Test: Click on the green flag and test your project again. Can you remember where you hid the bug?
In Scratch, code that is running glows with a yellow outline:
Tip: If the parrot gets too annoying while you are coding, you can click the red stop button above the
Stage to stop the code from running.
Step 5 Second level
Choose a backdrop to make a second level for your game,
and make the bug hard to find.
Add another backdrop
Choose: Choose a backdrop for your second level. We have chosen the Urban backdrop, but you can
choose the one that you like the most.
Tip: Remember that backdrops with lots of colours and details will make the bug harder to find. How
difficult will you make your game?
Stop the code from running
Drag the blocks away from the when this sprite clicked block to stop them from running when
you click on the bug:
Resize the bug
Add code to set the size of the bug for the second level:
when backdrop switches to Urban choose your backdrop
set size to 20 % try another size
Test: Click on your new script to run it.
Hide your bug
Drag your bug on the Stage to a good hiding place for this level.
Position your bug in its hiding place.
Add a go to x: y: block to your code:
when backdrop switches to Urban
set size to 20 % try another size
go to x: 24 y: 13 in the shop window
Test your code
Join the blocks back to the when this sprite clicked block so that when the bug is clicked, the
backdrop switches to the next backdrop:
Test: Click on the green flag to test your project.
Your bug may now be in front of the parrot.
Add a script to make sure that your bug is always at the back:
when clicked
forever
go to back layer
Now, your bug will always stay at the back, even if you need to change its position.
Step 6 End screen
Create an ‘end’ screen to show the number of seconds that
it has taken the player to find the bugs.
Sometimes, just beating a game isn’t enough. Players like to know how they did against other players or
themselves. Can you think of a game that shows you how well you did?
Add another backdrop
Add the Chalkboard backdrop from the Indoors category.
Tip: In Scratch, you can add the same backdrop more than once.
Edit the backdrop
Click on the Backdrops tab to open the Paint editor.
Change the name of the backdrop to end:
Tip: You rename the backdrop to end to make it easier to understand your code.
Position the bug
Click on the bug sprite and add code to position the bug on the ‘end’ screen:
when backdrop switches to end
set size to 100 % full-sized
go to x: 0 y: 30 on the board
Add a timer
How long does it take you to find and click on the bugs? Scratch has a timer that you can use to find out.
The timer block is in the Sensing blocks menu. Add code to make the bug say the timer on the ‘end’
screen:
when backdrop switches to end
set size to 100 % full-sized
go to x: 0 y: 30 on the board
say timer seconds taken
Test: Click on the green flag to test your finding skills. How long does it take you to find the bug?
To go back to the ‘start’ screen, click on the bug on the ‘end’ screen.
Add code to make the bug stop saying the timer when you go to the ‘start’ screen:
when backdrop switches to start
set size to 100 % full-sized
go to x: 0 y: 30 on the board
say say nothing
Stop the timer
If you play the game a second time, the timer will keep counting.
Add code to reset the timer when the backdrop switches to the first level:
when backdrop switches to Spotlight first level
set size to 20 % tiny
go to x: 13 y: 132 on the disco ball
reset timer start the timer
Test: Click on the green flag and play the game. The timer should reset when you click on the bug on the
‘start’ screen to move to the first level. When you click on the bug on the ‘end’ screen, you should return
to the ‘start’ screen and see that the bug is not saying the timer.
Upgrade your game
If you have time, you can add more levels and more distractions to your game. You could also change the sprite
that is hiding and change the text on the chalkboard.
Play your game and see how quickly you can find the bugs.
Is there someone else who can try your game? How fast can they find the bugs? They will not know
where you have hidden them, so it might take them a bit longer!
Is there anything that you want to change?
You could:
Make the parrot even more annoying
Make the bugs smaller
Change the color effect to camouflage the bug on each level
Change the font or colour of the text
Add more levels
Here are the blocks that you will need to hide the bug on a new level:
when backdrop switches to new level
set size to 20 %
go to x: 0 y: 0 drag to position the bug first
set color effect to 50
For each level, you will need to:
Add a backdrop
Click on the Stage pane, then on the Backdrops tab, then drag the new backdrop into position
before the end backdrop
Add a when backdrop switches to block for the new backdrop and add code to position and
hide the bug
Tip: To drag the bug to a new hiding position, you will need to ‘break’ the code so that the backdrop does
not switch when you click on the bug to position it for a new level.
Add more distractions
You could add more parrots or choose another sprite to act as a distraction.
Here is the code that you used for the parrot:
when clicked
set rotation style left-right do not go upside down
point in direction 35 number from -180 to 180
forever keep being annoying
move 10 steps the number controls the speed
if on edge, bounce stay on the Stage
next costume flap
change color effect by 5 try 11 or 50
wait 0.25 seconds try 0.1 or 0.5
Tip: You can drag the Parrot sprite’s code to another sprite to make it faster to create another
distraction sprite.
Completed project
You can view the completed project here (https://scratch.mit.edu/projects/486719939/).
Share and play
Inspire the Raspberry Pi Foundation community with your project!
Share your Scratch project
Please make sure that you do not share any personal information about yourself when sharing your
Scratch projects.
Give your Scratch project a name.
Click the Share button to make the project public.
If you like, you can add instructions in the Instructions box, to tell other people how to use your
project.
You can also fill in the Notes and Credits box: if you have made an original project, you can write
some short comments, or if you have remixed a project, you can credit the original creator.
Click the Copy Link button to get the link to your project. You can send this link to other people by
email or text, or on social media.
Scratch provides the ability to comment on your own and other people’s projects. If you do not want
to allow people to comment on your project, you should turn off commenting. To turn off commenting,
set the slider above the Comments box to Commenting off.
To submit your project to our ‘Find the bug’ Scratch studio for other people to see, please complete this
form (https://form.raspberrypi.org/f/community-project-submissions).
You can also look at the remixes for the Find the bug starter project (https://scratch.mit.edu/project
s/582214723/remixes) to see what other creators have made.
Save your project
What next?
If you are following the Introduction to Scratch (https://projects.raspberrypi.org/en/pathways/scratch-intr
o) pathway, you can move on to the Silly eyes (https://projects.raspberrypi.org/en/projects/silly-eyes)
project. In this project, you will design your own character with eyes that look at the mouse pointer when you move
the mouse!
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/find-the-bug)