Posted on

Scratch Coding – Witch’s Apple

Today we are building a game that features a witch flying on her broom across the sky. She can shoot falling objects like apples.

The game should have the following properties:

  • The user can move the witch up and down with the arrow keys.
  • The user can shoot a fireball by pressing the space key
  • When a fireball hits the falling object, the user gets a point
  • The background should look like the witch is flying.

Sprite Creation

We will need to create our own sprite for the moving clouds. Draw a new sprite and use the circle fill tool to make some join circles that will look like a cloud.

Other Sprites

We can add our witch, fireball and the object that falls from the sky.

Make the Clouds Move

We are going to use the glide block to make the clouds move across the screen. We always want the clouds to be moving, if we always want something to happen, we will use a forever loop.

We first move the clouds to the point on the screen where we want them to fly from. Move the ‘go to x and y’ block into our forever loop:

Then we move the clouds to the other side of the screen and drag up our glide block:

We also want the clouds to be a little transparent, in scratch this is the ghost effect:

We can change the speed of the clouds by changing the number of seconds the glide block takes to move across the screen.

Making the Witch Move

We want our witch to move up and down using the arrow keys. We know that the Y axis is for up and down, this means that we can add some change Y blocks onto our keyboard event hat blocks:

We use a negative number to make the witch go down.

We might notice that the clouds are in front of the witch, we can also bring her to the front of the screen when our game starts.

Falling Apples

We are going drag the apple to the top of the screen on the right hand side where we want it to fall from. Since the Y axis is for up and down we will use some change Y blocks to make the apple fall.

We always want our apple to be falling, so we need to use a forever block:

Use a negative number for the y position to make it move down.

Shooting Fireballs

We can have our witch shoot a fireball by cloning the fireball sprite and moving it towards the mouse position.

We must first move the sprite to where the witch is on the screen, then create a clone of the fireball sprite:

When the clone starts up, we want to point it towards the mouse position and move it until it hits the edge of the screen at that point we want to delete the clone.

Make the fireball hidden at the start of the game.


To keep score we are going to need to use a variable, let’s call it score.

On our fireball, we are going to set this to zero when the game starts:

We need to test our apple to see if it is touching a fireball object, we can use an if block for a test.

Our forever block now looks like:

Make our Apple Fall from Different Places

At the moment our apple always falls from the same position in the sky, we can add a random block into the ‘go to X Y’ block. I only want my apples to fall from different X positions on the screen (across ways), rather than from different heights. So I added a random block to the X position.