Create Your First Game

Lesson 4 of 7

Storytelling

Craft compelling game narratives through environmental storytelling, quests, and branch points.

🟡 Intermediate 70 XP

Learn it

Games let players experience stories from the inside, putting you directly in the shoes of the main character.

You can tell a story without walls of text. A broken shield on the floor or a dark castle on the horizon tells players that danger is near without a single word.

Branching narratives let players make choices that change how the story unfolds, creating different endings based on what they decide to do.

Key terms

Environmental Storytelling
Using level design, props, and lighting to communicate history and lore.
Narrative Branching
Story structures where player choices lead to divergent outcomes and endings.
Story Flag
A boolean variable used by developers to track whether a story event has occurred.
Cutscene
A non-interactive or semi-interactive animated sequence that advances the plot.

Building a Branching Dialogue Tree

Map out a conversation where player choices alter the story path.

  1. 1Write the Prompt: Create an NPC question that presents a moral dilemma or tactical choice.
  2. 2Offer Distinct Choices: Provide at least two contrasting dialogue responses for the player.
  3. 3Set a Story Flag: Use a boolean variable like has_spared_goblin = True to record the decision.
  4. 4Trigger Consequences: Write unique NPC reactions and future level modifications based on that flag.

Story Flag Branching

python# Checking story flags to determine dialogue
helped_blacksmith = True

if helped_blacksmith:
    dialogue = 'Take this forged blade, champion. You earned it!'
    grant_item('Flame Sword')
else:
    dialogue = 'I only forge steel for friends of the forge.'

print(dialogue)

The story flag helped_blacksmith determines which dialogue option runs and whether the player receives an item reward.

Try it

Predict what will be printed when this narrative flag script runs.

pythonkeys_collected = 3
has_boss_pass = False

if keys_collected >= 3:
    has_boss_pass = True

if has_boss_pass:
    print('The vault door swings wide open!')
else:
    print('The heavy door remains locked.')

Challenge

Write a 3-stage mini quest using environmental cues and two story flags: has_torch and solved_riddle.

Pick whichever way suits you — every mode earns the same bonus XP.

Write at least 40 more characters to submit.

Mark your own work

Guided walkthrough — 0/5 clues revealed

  1. Clue 1 locked — reveal it only if you get stuck.
  2. Clue 2 locked — reveal it only if you get stuck.
  3. Clue 3 locked — reveal it only if you get stuck.
  4. Clue 4 locked — reveal it only if you get stuck.
  5. Clue 5 locked — reveal it only if you get stuck.

Each clue costs 4 XP (never below 18 XP). You'd earn 35 XP right now.

Extension: Diagram the quest as a flow chart showing all possible success and failure paths.

Quiz time

Question 1 of 4Score 0

What is environmental storytelling?