Code a quiz or interactive story
Lesson preview: the Mini Lesson and Vocabulary are open to everyone. Guided practice, exercises, the parent checklist and the printable PDF worksheet come with full access (free 7-day trial or membership).
Learning Objectives
- 1Plan an interactive story with an opening scene, two choices, and an outcome for each branch
- 2Match each story choice to the outcome it should lead to
- 3Use variables, events, and conditions to score a quiz and follow a story branch
- 4Test the quiz or story and rewrite any branch that confuses the player
Mini Lesson
A quiz asks the player a question, checks their answer, and updates a score. An interactive story tells a scene, asks the player to choose, and then jumps to a different scene depending on the choice. Both are built from the same parts: text on screen, a choice the player makes, a condition that checks the choice, and a variable that remembers what happened so far. Plan every branch on paper first, then code one screen at a time.
The Branching Script Frame
- Opening scene — set the place, the character, and the problem in one or two sentences.
- Choice A — the first thing the player can decide to do.
- Outcome A — what happens, in detail, after the player picks Choice A.
- Choice B — the other thing the player can decide to do.
- Outcome B — what happens, in detail, after the player picks Choice B.
- Ending — how the story closes (or which branch it loops back to).
How a Quiz Works
- A variable called score starts at 0.
- Each question is shown one at a time, with four options labeled A, B, C, D.
- When the player taps an option, an event fires.
- A condition checks: was that the right answer? If yes, score = score + 1.
- After the last question, the program shows the final score and a message.
How an Interactive Story Works
- Each scene is one screen of text plus two or three buttons.
- When the player taps a button, an event fires and the program jumps to the next scene.
- The next scene depends on the choice — that is the BRANCH.
- A variable can remember things across scenes (did the player open the door, take the sword, talk to the dragon).
- Endings are reached when no more buttons are shown — the story is over.
You write: "You stand in a dark forest. A path leads left and a path leads right." What four parts of the script frame do you need to plan?
Every choice ALWAYS pairs with its own outcome. If you write Choice A but forget Outcome A, the program has nowhere to go. The branching script frame forces you to write both halves before you start coding.
Test, Tune, Repeat
- Play every branch yourself — pick A every time, then play again and pick B every time.
- Watch a friend play. If they freeze on a choice, the wording is unclear.
- Make sure no choice leads to a dead end with no buttons unless you mean it as an ending.
- For a quiz, double-check every right answer in your code matches the question.
- For a story, read every outcome aloud — does it follow naturally from the choice?
Tip: write every choice and every outcome on paper FIRST. If you can’t finish the sentence "if the player picks A, then ___", your branch is broken before you ever open the editor.
Unlock the full HSEA system for 7 days.
Add your first kid profile and your 7 days start: every lesson in every grade, saved progress for each child. Nothing to set up, no card required, nothing to cancel.
- ✓ All 1,680 lessons, Grades 1–6, every subject
- ✓ Profiles + saved progress for every kid
- ✓ Printable lessons with answer key