This project is inspired by the amusement park game Whack-a-mole where the player strikes moles back down into their holes.
Hey 😃 In our game we will program the ghosts to disappear when we click them.
The goal is to click remove as many as possible in 30 seconds.
Start a new, empty, project and delete the cat
Open the Scratch Editor
You can find the online Scratch editor at icomp.site/scratch
Change the backdrop to
To add a ghost, click Select the sprite
Give the ghost the name
variablethat controls how fast the ghost moves
Codesection choose the
Now click the button
Name the new variable and check For this sprite only
On the stage, you will see the variable is called
Uncheck the box next to the variable so that it does not appear on scene:
We want the ghost to move when the game starts. We can do this by creating the following script:
when green flag clicked set [speed v] to  forever move (speed) steps end
Does the ghost fly across the screen?
Why is the ghost stuck when it hits the edge of the screen?
if on edge bounce
when green flag clicked set [speed v] to  forever move (speed) steps if on edge bounce end
Change the speed variable so that the ghost runs faster or slower
How can we make the ghost fly faster the longer it flies?
Let's make the ghost appear and disappear!
We will now create a new script, which will run at the same time as the script as moving on the ghost
The new script shows the ghost for a random amount of time and then hides it again after a random time
when green flag clicked forever show wait (pick random (3) to (5)) secs hide wait (pick random (2) to (4)) secs end
pick random () to ()
Make the ghost disappear!
Go to the
Sounds tab, add a new sound
Search for the sound
Fairydust in the search field and
Now create a script that will make the ghost disappear when the player clicks it
when this sprite clicked hide start sound [fairydust v]
Add score and a time limit
Create a new variable called
Make sure this one applies
For all figures
Now add a new block so that the
score variable is increased by 1 point
each time the player clicks the ghost
when this sprite clicked hide start sound [fairydust v] change [score v] by (1)
Next create a new variable called
This variable can show on the screen
Now add a new script that sets the
time variable to
score variable to
0 when the green flag is clicked.
Then use a
repeat until block to
1 second before reducing the time by 1 second
This should run until time runs out
When the time runs out, you should stop the game with
When green flag clicked set [time v] to  set [score v] to  repeat until <(time) = > wait (1) seconds change [time v] by (-1) end stop [all v]
Good job! You've made an amazing Whack a Ghost game! Follow the next steps to make it even better!
One ghost is good, but more is even better! Let's have three ghosts flying around!
Make the ghosts be different sizes by choosing a ghost and changing
the number in the
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Derived from work at https://github.com/kodeklubben/oppgaver/tree/master/src/scratch/spokelsesjakten