New! Explore our Programming Academy and AI Tutor - learn to code from scratch, free to start. Explore Now
Programming› Scratch› Project: Build a Story Game

Project: Build a Story Game

💻 Scratch

Combine scenes, dialogue, choices and a score into a complete short game.

Lesson 9 of 9 Project
0 of 9 completed

A story game lets the player make choices that change what happens. This project brings together everything from the Scratch course.

By the end of this lesson you can:
  • Plan a short branching story.
  • Switch backdrops and broadcast messages.
  • Track the player's score or ending.

Plan the Story

Write three scenes: a beginning, a choice and an ending. Keep it short enough to finish. Decide what each choice changes.

Switch Scenes

Use switch backdrop to and broadcast to move between scenes. Each scene can have its own sprite dialogue.

when green flag clicked
switch backdrop to [forest v]
broadcast [scene one v] and wait

when I receive [scene one v]
say [You find two paths. Which way?] for (3) seconds
ask [Type left or right] and wait
if <(answer) = [left]> then
  broadcast [river ending v]
else
  broadcast [mountain ending v]
end

Finish and Test

Make sure every path reaches an ending. Test each choice, check spelling, and add a way to restart. Ask a friend to play without instructions and watch where they get stuck.

Tip Keep the first version small. A short game that works is better than a long game that never ends.

Practice

  1. Add a third scene with a different choice.
  2. Create a score that rises when the player makes a good choice.
  3. Add a restart button that broadcasts the opening scene.

Hands-on exercise

Build the branching scene from this lesson.
1. Ask the player to choose left or right.
2. Show one ending for left and another for right.
3. Make sure the project stops or offers a restart after the ending.

Recap

A story game needs a plan, clear scenes and tested endings. Broadcasts and backdrops keep the scenes organised.

Example

when green flag clicked
switch backdrop to [forest v]
broadcast [scene one v] and wait

when I receive [scene one v]
say [You find two paths. Which way?] for (3) seconds
ask [Type left or right] and wait
if <(answer) = [left]> then
  broadcast [river ending v]
else
  broadcast [mountain ending v]
end

Exercises

Exercise 1. Two endings Medium
Build the branching scene from this lesson.
1. Ask the player to choose left or right.
2. Show one ending for left and another for right.
3. Make sure the project stops or offers a restart after the ending.
Scratch exercise-1.txt
Expected Output
The project shows a different ending for left and for right.

Lesson Nav

Lesson sections