Lesson / Scratch & Game Design

Where Does the Score Live?

The space pet insists it was fed, but the program has forgotten. Give its needs names, decide what changes them, and make every new game start with a clean memory.

Lesson plan

  1. What must the pet remember?

    Choose two changing needs and give each one a useful name.

  2. Start, change, read

    Set a value, update it from an event, and use it in a condition.

  3. Build the pet

    Add care actions, time-based change, and a visible state.

  4. Break the reset

    Create a stale value deliberately, then repair the initialization.

  5. Follow one value

    Show where a variable starts, what changes it, and which rule reads it.

Learning goals

  • Give a variable a useful name.
  • Set its starting value.
  • Update it when a particular event occurs.
  • Read it in a condition.
  • Distinguish the stored value from its on-screen display.

Small examples

set mood to 5

give mood a starting value

change mood by -1

update mood over time

if mood < 2

make a decision from the stored value

set game_state to PLAYING

record the current mode

Guided project

The Suspiciously Emotional Space Pet

Keep an alien pet fed, rested, and reasonably trusting. It remains suspicious of the snack button.

Build This Project
Students build

At least two changing needs, Actions that affect those needs, Visible mood or state, Time-based change.

Ideas in use

Variables, State, Events, Conditions, Timers.

Finish line

A working version with a tested change, one repaired problem, and a clear explanation.

Teacher checkpoints

  1. 1The variable name describes what it stores.
  2. 2Restarting restores the initial value.
  3. 3One event changes the value once.
  4. 4At least one condition reads the value.
  5. 5The student can explain the current state.

Common mistakes

  • Variable never resets.
  • Several scripts change the score unexpectedly.
  • A display is hidden but the value remains.
  • Text and number values are compared accidentally.

Optional challenges

LEVEL 1

Builder

  • Add a second need such as energy.
LEVEL 2

Inventor

  • Make needs affect each other.
LEVEL 3

Boss Level

  • Create named pet states from several variables.

End-of-class demonstration

  1. What does the variable remember?
  2. Where is it initialized?
  3. Which event changes it?
  4. Which decision reads it?
  5. What state is active now?