Stage 1: Create the Cube Runner
Stage 1: Create the Cube Runner
Keep your Scratch project tab open all week. Open in a new tab so you don’t leave the course.
a Cube sprite and clean Scratch project
how sprite names and costumes become the foundation of a game
a player cube ready for jumping
- Open the saved Scratch project and delete Scratch Cat.
- Create a new sprite named Cube. Either paint a square face or use the target cube as a drawing reference.
- Place it near the left side of the stage at x: -150 y: -90.
- Create variables ySpeed, gameOn, score, and gravity for all sprites.
- Click the green flag and show the cube resetting to the same place every time.
The big idea
A runner game works because the player stays predictable. The cube is the anchor. Everything else in the level scrolls toward it.
- sprite
- a character or object in the Scratch project
- costume
- one look a sprite can wear
- variable
- a named value Scratch remembers while the game runs
- reset
- putting the game back into a known start state
Setup should be complete. Your project is named Geometry Dash - First Last and saved to your Scratch account.
Students may follow these examples or draw their own versions in Scratch. Keep the sprite names from the lesson.
Follow the target shapes shown here so your scripts match the lesson quickly.
Draw a custom cube, spikes, portal, or backdrop in Scratch. Keep the same sprite names so the code still works.
Build it
- Delete Scratch Cat, then make a new sprite named Cube.
- Paint a square with a face. Use bright colors and thick outlines so it reads clearly while moving.
- Make four variables for all sprites: ySpeed, gravity, gameOn, and score.
- Add the setup script below to the Cube sprite.
- Save the project after the cube resets correctly.
Cube setup script
when green flag clicked set [gameOn v] to (1) set [score v] to (0) set [gravity v] to (-1) set [ySpeed v] to (0) go to x: (-150) y: (-90) show
Cube
Understand it
The green flag script is initialization. It makes every playtest start from the same state, which matters once the cube can crash, win, or restart.
Try this
Try this
Three short experiments. Predict before you run, then test your guess.
Test your stage
- The player sprite is named Cube exactly.
- The cube starts at x: -150 y: -90 when the green flag is clicked.
- Variables ySpeed, gravity, gameOn, and score exist for all sprites.
- The project is saved.
If it breaks
- If the cube does not move to the start spot, check that the script is on the Cube sprite.
- If a variable is missing later, recreate it with the same spelling and choose For all sprites.
Keep students moving on the default path first. Custom assets are encouraged, but the required names and variables are not optional. If debugging takes more than a few minutes, compare the student's sprite names, variable names, and block order against the stage test list.