Platform Game Tutorial – Part 3

This is part three of a three part series about making a platform game in Scratch. In this tutorial we’ll be adding a goal for our character to reach, new levels, and an ending screen.

Star Light, Star Bright…

Let’s add our goal, a star. Click on the paint new sprite button Paint New Sprite to add our star sprite. Using the paintbrush tool, and a dark yellow color, draw the outline for your star. Don’t worry if it’s not perfect!

Star Outline

Next, select the fill tool and the bright yellow color and fill the star in:


Click OK to save your star once you’re finished. If it seems too big on the screen you can shrink it down using the shrink tool Shrink. Rename the sprite to “Star”.

Switch to the scripts tab to add a script for our star. When the green flag is clicked we want the star to be hidden. When the game starts we want the star to appear above the upper platform.

Star Script Initial

If you run the game now, you should see the star appear above the upper platform like so:

Level One With Goal

However, nothing happens if our blue guy reaches the star! Not yet at least, let’s fix that…

Reach for the Stars

Go to the variables palette and add a new variable for all sprites called “Level”:

Level Variable

Now let’s switch back to the scripts tab for the blue guy sprite. When our blue guy touches the star we’ll increment the level and broadcast the message “Next Level”. In order to avoid incrementing the level more than once, we’ll hide our blue guy and move him to a different location on the stage before we show him. This way he won’t be touching the star on the next pass of the loop. We should also set the value of Level to 1 when the game starts off. Here’s what the blue guy script looks like now:

Blue Guy Script Touching Star

More Levels

Since we only have one level at this point, nothing interesting will happen when the blue guy touches the star. We need to add at least a couple more levels.

Following the steps that you took to create the first level (in the previous tutorial) add at least two more levels. You can do anything your heart desires with the levels, just be sure that it will be possible to get the star on each level because otherwise that won’t be any fun!

Here are some examples for the next two levels:

Level Two

Level Two

Level Three

Level Three

Before this will work, we need to add code that will switch to the next costume each time the Level sprite receives the “Next Level” message. Here is the updated script for the level:

Level Script Next Level

Finally, switch to the star sprite script and add code to move the star to a new location when the star sprite receives the “Next Level” message. Locate the star in a spot that makes sense for that level. The coordinates that I provided below are for the level layouts that I had created:

Star Script Next Level

OK, that’s it… Test out the game now. Does it work? What happens when you get the star on the last level? Hmmm…

Game Over

The final step in completing our game is to show a screen with the message “You Win!” after the blue guy reaches the last goal.

First, let’s add an if-else block to our blue guy’s script. If the value for our level is greater than 3 (our last level), then we’ll broadcast the message “Game Over”, otherwise we broadcast “Next Level”, reposition the blue guy and show him. Here’s the final version of the blue guy script:

Blue Guy Script Game Over

Now, let’s change the script for our star so that the star is hidden when it receives the “Game Over” message:

Star Script Game Over

We also want the level sprite to be hidden at the end of the game:

Level Script Game Over

Finally, we need to add a new background for our stage that we’ll show at the end of the game. Switch to the stage and click on the backgrounds tab. Now click paint to create the “You Win!” background:

You Win

Almost there…Switch to the scripts tab for the stage and add blocks to handle when the green flag is clicked (show intro background) and when the Game Over message is received (show the You Win background):

Stage Script Game Over

That’s it! Try playing the game now…Can you get the “You Win!” screen to appear?

Final Thoughts

I hope you found this tutorial helpful. If you’ve had any problems, the completed game can be found on the Scratch website at:

Now, go make your own platform game!


Robert is a graduate of Fairfield University in Fairfield, CT and has been developing software professionally for fifteen years. He is the father of two children who have been making their own games using the Scratch programming language.

Posted in Intermediate, Scratch, Tutorial Tagged with: , ,