Video Game Design and Coding · PLECK lesson

PLECK lesson 84 · suggested week 17, day 4

Make a complete replay loop

Objective. Verify every ending returns to a clean playable start.

Godot Engine Standard desktop editor 4.7.2-stable, GDScript (Godot 4), Compatibility renderer. Headless Godot 4.7.2.stable.official.ed1daf0bf passed 106 assertions on the supplied scaffolds, including malformed JSON saves. Audio used the Dummy driver and a synthetic WAV, not a speaker. The visual editor, browser export, and signed-in submission were not tested. The desk still does not run a student's own upload.

About 55 minutes. The due date is chosen by a parent.

Reliable input, challenge, feedback and reset integration

Suggested pace: Recall and predict 5 min; Read instruction and scaffold 12 min; Build or design the assigned artifact 25 min; Run acceptance tests 8 min; Explain and checkpoint 5 min.

Materials: Godot Standard 4.7.2 desktop editor (GDScript, Compatibility renderer), Local course folder and prior checkpoint, No paid assets or public account required.

Comes after VGC-L083.

Finish Restart or New Round with the reset policy in your proposal. List every state item that must reset, including hidden flags, cooldowns, clock, inventory and checkpoint. If you use scene reload, confirm pause is cleared before reloading and that any global state has a deliberate policy. Play two full rounds with different outcomes if the game has both win and loss. A replay test catches state leaks that a fresh editor run hides.

Worked example

An input-to-feedback chain might be movement, pickup overlap, collected signal, manager score increment, then label refresh. Each stage has one clear responsibility. Scaffold C-STATES — Explicit game states and gated scoring Setup: Attach to Node root StateLab with child Label Status. This is a standalone demonstrator; call start_round, add_points, finish_round from buttons or Remote Inspector. In a real game the manager owns this state. Additional Player and spawner scripts must also honor the manager’s state, or be disabled when finishing. ```gdscript extends Node enum Phase { TITLE, PLAY, WIN, LOSE } var phase: Phase = Phase.TITLE var score: int = 0 func _ready() -> void: _show() func start_round() -> void: score = 0 phase = Phase.PLAY _show() func add_points(amount: int) -> void: if phase != Phase.PLAY: return score += maxi(amount, 0) _show() func finish_round(won: bool) -> void: if phase != Phase.PLAY: return phase = Phase.WIN if won else Phase.LOSE _show() func _show() -> void: $Status.text = "State: %s | Score: %d" % [Phase.keys()[phase], score] ``` Scaffold C-PAUSE — Pause with an always-processing resume control Setup: Node2D World root has CanvasLayer HUD with Button Pause, plus normal gameplay children. Set Pause button Process > Mode to Always in Inspector; leave World and gameplay as Inherit/Pausable. Attach script to World; merge into its existing _ready if present. Signal callbacks still work from the always-processing button. Label text starts Pause. ```gdscript extends Node2D func _ready() -> void: $HUD/Pause.pressed.connect(_toggle_pause) func _toggle_pause() -> void: get_tree().paused = not get_tree().paused $HUD/Pause.text = "Resume" if get_tree().paused else "Pause" ```

Explicit game states and gated scoring

GDScript (Godot 4, not Scratch, Python, JavaScript or C#). Scaffold C-STATES. Copy starts from this text. The desk does not run it.

Scene and node setup

Attach to Node root StateLab with child Label Status. This is a standalone demonstrator; call start_round, add_points, finish_round from buttons or Remote Inspector. In a real game the manager owns this state. Additional Player and spawner scripts must also honor the manager’s state, or be disabled when finishing.

extends Node
enum Phase { TITLE, PLAY, WIN, LOSE }
var phase: Phase = Phase.TITLE
var score: int = 0
func _ready() -> void:
    _show()
func start_round() -> void:
    score = 0
    phase = Phase.PLAY
    _show()
func add_points(amount: int) -> void:
    if phase != Phase.PLAY:
        return
    score += maxi(amount, 0)
    _show()
func finish_round(won: bool) -> void:
    if phase != Phase.PLAY:
        return
    phase = Phase.WIN if won else Phase.LOSE
    _show()
func _show() -> void:
    $Status.text = "State: %s | Score: %d" % [Phase.keys()[phase], score]

Checks to run in the editor

Native Godot 4.7.2.stable.official.ed1daf0bf headless compile and representative node-tree/runtime tests passed; see native-qa-results.json. Visual UI, audible output, exports and website submission still need separate checks.

Pause with an always-processing resume control

GDScript (Godot 4, not Scratch, Python, JavaScript or C#). Scaffold C-PAUSE. Copy starts from this text. The desk does not run it.

Scene and node setup

Node2D World root has CanvasLayer HUD with Button Pause, plus normal gameplay children. Set Pause button Process > Mode to Always in Inspector; leave World and gameplay as Inherit/Pausable. Attach script to World; merge into its existing _ready if present. Signal callbacks still work from the always-processing button. Label text starts Pause.

extends Node2D
func _ready() -> void:
    $HUD/Pause.pressed.connect(_toggle_pause)
func _toggle_pause() -> void:
    get_tree().paused = not get_tree().paused
    $HUD/Pause.text = "Resume" if get_tree().paused else "Pause"

Checks to run in the editor

Native Godot 4.7.2.stable.official.ed1daf0bf headless compile and representative node-tree/runtime tests passed; see native-qa-results.json. Visual UI, audible output, exports and website submission still need separate checks.

Make a complete replay loop — evidence task

  1. 1. Implement replay and run two consecutive rounds.
  2. 2. Compare all reset-state items at each start.

Deliverable. Replay checkpoint and reset-state comparison.

Acceptance checks

Understanding question. Why can restarting the editor hide a reset bug?

Include a downloadable project ZIP with project.godot, .tscn, .gd and original asset files when code changes. A private, teacher-accessible download link to that ZIP is equivalent. Screenshots or a playthrough do not replace editable source.

If this is still shaky. Use your state-owner diagram to fix one system at a time. Keep the vertical-slice checkpoint available for comparison. Start with the first assigned task and re-run its acceptance test before adding the remaining feature.

Optional extra. Add one optional challenge only after the complete minimum loop passes. Document one changed parameter, your prediction, and the observed effect; optional, not required for completion.

Name ____________________ Date ____________________