Posted on

Scratch Coding – Monkey Platformer

We are going to build a game where a monkey must collect some moving objects. This monkey will have the ability to jump across the platforms in order to get the height needed to collect the balls.

The monkey should move in the following way:

  • Left arrow makes the monkey run to the left
  • Right arrow makes the monkey run to the right
  • Up arrow makes the monkey jump in the air


We can start with the following sprites:

Monkey Jump

We can make our monkey jump with the up arrow, but we need to change the monkey movement so that the monkey falls back to the ground.

Since we selected a nice backdrop with some brown ground, we are going to always be changing the Y position of the monkey when it is not touching the brown colour.

If we test this, we see that our monkey doesn’t do much, if we start our game with the monkey in the air, we see that the monkey will fall to the ground.

To make the monkey now jump we just have to add a little push upwards:

I’ve also added a check here to make sure the monkey is standing on the ground when he does a jump.

Monkey Move

At the moment all our monkey can do is jump, we can add some code to make this monkey move!

We check to see if the keys are pressed and if they are, we then move the monkey on the X axis. We also switch to the next costume to make it look like the monkey is running.

Make the Ball Move

The goal of the game is to have balls moving across the screen for the monkey to catch. Let’s switch to the ball and get it moving.

Since we want a number of balls to be flying at the monkey at the same time, we are going to use a clone. To set this up we add:

This means a new ball will be created every 1 second. You might like to make this larger if too many balls are coming at the player.

Now when the clone is created we move it to the left hand side of the screen and start its movement.

We ask for a random spot and then set the X to the right most position. We repeat until we move to the left hand side of the screen. If we touch the monkey along the way, then we delete the clone. Also if we get to the left hand side of the screen, we also delete the clone.

Keeping Score

We can add a new variable and use that to keep track of how many balls the monkey has caught. Call this variable ‘Score’, we should have some new blocks:

Now on our monkey sprite, we need to add a check for our scoring:

Once we touch the ball the score is changed by 1.

Running Out of Time

Let’s add a timer so that we can give our player just a small amount of time to collect the balls.

On the backdrop, add a new variable called ‘timer’.

We then add some code that will count the timer down to zero. First I set the timer to 30 seconds, then I repeat until the timer is zero, changing the value of timer down by one each second. After the timer is zero, we stop the game.

Now we can draw some more platforms to make our game easier.