Today we'll show you how to make a Frogger Game on Scratch in a few simple steps. You'll learn how to add levels, make faster objects, and much more. Let's get started! If you enjoy making games be sure to join our fun live online game design club led by an expert, or begin with our free Scratch class, designed by professionals from Google, Stanford, and MIT.

Discover how to make a frogger game on Scratch

We'll guide you from creating your sprites through to adding lives, and making the finish line.

1. Select your sprites.

You will need 1 character to “cross the road”, 4 obstacles to dodge, and a finish line. If you would like to use the sprites and backdrops from the example, then you can remix this empty version of the project that has the sprites without the code.

2. Give your frog a starting x and y position.

The x-coordinate will tell the frog its side-to-side position, while the y-coordinate tells the frog its up-and-down position.  You can also give the frog its starting direction, by pointing it straight up (direction 0).    

Give frog starting position

3. We will move our frog up, down, left, and right.

To move the frog put 4 if-then statements inside of a forever loop.  If-then statements check if something is true, and if it is then the code inside of the statement will begin.  For example, if the up arrow is pressed, then we will point the frog up and move it forward.  We will create an if-then statement for each of the 4 arrow keys.

Create an if statement in scratch

4. Next, we will make the obstacles move across the screen.

To do this, we will utilize cloning to make copies of the obstacle. Some obstacles will start on the right side and move left while others will move left to right. Make sure the obstacles start at different heights (y-positions), so that they don’t appear to be running into each other.

To keep the player on their toes, the clones will be created at random times by using the pick random operator block. When working with clones, it is important to make sure that you hide the original sprite from the screen but show the clones.

You can tell the clones to immediately show by using the show block from the Looks category and use a repeat until block to move them across the screen.  Repeat until blocks are incredibly useful loops that continuously repeat the code until the statement inside is false. In this case, the statement that we are investigating is the x-position of the obstacle clone. For the sprites moving to the right, the x-position will continue to grow and once it is greater than 280 we delete the clone. The opposite is true for the clones moving to the left.

Obstacles Moving Left to Right

Obstacles moving left to right

Obstacles Moving Right to Left

Code to move right to left

5. Broadcast a message.

If the frog touches the moving car, then we will broadcast a message to the entire project. Broadcasting and receiving blocks allow our code to communicate across characters.

In this scenario we want the obstacle clone to check whether it is touching the frog, and if it does, we want to send a signal to the entire project that the frog has been hit.

Show a message

The frog character will receive this signal and immediately reset back to the bottom of the page. We can also include a stop all block, so that the entire project shuts off.

Shut the project off

6. Make the finish line message.

Similarly, we want the finish line to also check whether it touches the frog character. If the frog successfully makes it to the finish line, then we will send a different message (ex. level up). For now, we will simply have the frog reset back to the bottom if it reaches the end.

Finish Line

Finish line message

Frog

Frog message

7. Add lives and more.

To create a more challenging and fun game, we will add Lives, Points, and Level variables.  A variable is a memory box within the game, so that the code can track and remember important information.

You can create a variable for each of these in by clicking on Make a Variable in the Variable blocks category.  Make sure to press For all sprites, because we want the information to be shared to all the characters.

Add lives

When the green flag is clicked to start the game, the Points will be set to 0, the Level will be set to 1, and the Lives will be set to 5.

Add points

When the frog receives the message that it has reached the finish line (level up), the Level variable will increase by 1 and the Points variable will increase by 10 to give the player a higher score.

Level

When the frog receives the message that frog is hit, then we will subtract 1 from the Lives variable and 10 from the Points variable.  Additionally, we will check if the Lives equal 0.  If the player runs out of Lives for their frog, then we will stop the game.

Code a frogger game

8. Add levels.

The Level variable will make the game become more difficult as the player continues to advance. The Level variable will accomplish that task in two different ways. First, it will make the obstacles create clone more frequently as the Level increases.

By using an if-then-else block, we can make the code check what Level the player is on. If-then-else blocks operate similarly to if-then blocks, but the key difference is that an if-then-else block allows us to provide an option to the code if the statement is false.  

For example, if the level is greater than six, then the clones will wait between 1 to 3 seconds to be created, or else the clones wait between 1 to 10 – Level. So, if the player is on Level 3 (which is not greater than 6), the clones will be created a random number of seconds between 1 to 10 – 3, or 7. The if-then-else block allows us to make sure that the obstacles are not created instantaneously or at a negative time when the Level variable is high.

Add levels on Frogger game

9. Make the obstacles move faster.

The second way we can make the game more challenging, is by making the obstacles move faster depending on the Level variable. This will require a new variable called Speed that we can set at 6 to start the game.

Make obstacles move fast

After leveling up, the code will check if the Level mod 3 is equal to 0. The mod block gives the remainder of the first input divided by the second input. By checking if the Level is divisible by 3, we can increase the Speed variable by 3 steps gradually.  This will mean that at Level 3, the Speed will increase to 9. And at Level 6, the Speed will increase by 3 more steps to 12, and so on. Adding this code ensures that the Speed does not become too large, too fast.

Code in Scratch

To make the obstacles move more quickly, we will add the Speed variable into the change x block. For the obstacles going from the left to the right, change the x coordinate by the Speed variable, because we want the x-position to increase. For the cars going from right to left, change the x coordinate by 0 minus the Speed variable, because we want the x-position to decrease (change by a negative number).

Obstacles Moving Left to Right

Scratch game coding

Obstacles Moving Right to Left

Right to left

10. Keep creating!

Make sure to continue building, testing, and debugging your game. This is just a start to what you can create! Some interesting challenges could be adding a Game Over screen, background music, or more obstacles to frustrate the player.

Now you can make a frogger game on Scratch

You're ready to make a cool Frogger game that's all your own. To find out how to make more fun games with live expert guidance, join our free Scratch class, designed by professionals from Google, Stanford, and MIT - start with Scratch Ninja for Grades 2-5 or Accelerated Scratch for Grades 5-9.

Up next, learn how to create a musical app or a PacMan game in Scratch.

Written by Matt Kalnay, a Create & Learn instructor. After graduating from UC Davis with a B.S. in Biology, he joined Peace Corps Indonesia as an English as a Foreign Language Instructor. Following his return to the United States, he decided to pursue his passion in the field of Software Engineering and Web Development.