Project 11 of 35  ·  Scratch Programming  ·  Level 2
Level 2

Don't Fall In

Create a platform game where the player must avoid falling into danger zones below.

🍓  Open on Raspberry Pi Projects  ↗ Opens the official Raspberry Pi Foundation project — includes starter files and full step-by-step guide

What You Will Build

Create a platform game where the player must avoid falling into danger zones below. Follow the guide below to build the project, then open the official Raspberry Pi page for starter files, worked examples and extra help.

🍓 This project is on the Raspberry Pi Foundation website. Click the orange button above to access the full guide, starter Scratch project and extension activities on projects.raspberrypi.org.

What You Will Learn

  • Simulate gravity using a y-velocity variable
  • Detect collisions with platform sprites using touching color
  • Use arrow keys and spacebar for movement and jumping
  • Track lives using a variable
  • Reset position when the player falls off screen

Step-by-Step Guide

  • 1Create a lava or pit backdrop.
  • 2Add a player sprite and 4 platform sprites arranged across the stage.
  • 3Create variables: yVelocity, lives (set to 3).
  • 4In a forever loop: change y by (yVelocity) then change yVelocity by -1 (gravity).
  • 5If touching [platform]: set yVelocity to 0 and set y to (y + 2) to sit on top.
  • 6If < [up arrow] key pressed>: set yVelocity to 10 (jump).
  • 7If < [right arrow] pressed>: change x by 4. Left arrow: change x by -4.
  • 8If y position < -160: change lives by -1, reset position to start.
  • 9If lives = 0: stop all and show Game Over.
  • 10Add a moving platform that slides back and forth.

Extension Challenges

Finished the main project? Push further:

  • Add collectible coins on platforms that add to a score.
  • Add an enemy that patrols one platform and resets lives if touched.
  • Add a second level that loads as a new backdrop when the player reaches the right edge.