Video Game Design and Coding · PLECK lesson
PLECK lesson 154 · suggested week 31, day 4
Complete progress and end-state feedback
Objective. Keep the player’s view consistent with authoritative state.
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.
Input robustness, rule completion, challenge and progress
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-L153.
Implement every required progress display and both the active and ended views. Test start, middle and completion values. A progress bar, number or story flag should derive from the manager or data owner. Make completion unmistakable using text and a non-color cue. Stop or gate obsolete gameplay after ending so score, damage and timers cannot continue changing. If there is only a win state, explain how the player can restart or leave without waiting.
Worked example
A repeat-input test might press a one-time choice rapidly. The accepted event happens once, while later calls observe the changed state and do nothing. 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-MANAGER — A complete three-coin collection round Setup: Create World Node2D root with Player (C-BODY), three Coin instances (C-PICKUP), and CanvasLayer HUD > Label named Score plus Button named Restart (text Restart, position 500,10). Root and parents unscaled. Name coins Coin1, Coin2, Coin3. Place them at (250,100),(380,220),(520,100). Player group player. Attach script to World. UI paths and coin names must match exactly. Connect nothing else in the editor. Label at (10,10). ```gdscript extends Node2D var score: int = 0 var playing: bool = true @onready var score_label: Label = $HUD/Score func _ready() -> void: $HUD/Restart.pressed.connect(_restart) for coin in [$Coin1, $Coin2, $Coin3]: coin.collected.connect(_on_collected) _refresh() func _on_collected(points: int) -> void: if not playing: return score += points if score >= 3: playing = false $Player.set_physics_process(false) _refresh() func _refresh() -> void: score_label.text = "Score: %d / 3" % score if not playing: score_label.text += " — Orchard complete!" func _restart() -> void: get_tree().reload_current_scene() ```
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
- Calling add_points before start does not change score.
- After finish_round, extra score events do nothing.
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.
A complete three-coin collection round
GDScript (Godot 4, not Scratch, Python, JavaScript or C#). Scaffold C-MANAGER. Copy starts from this text. The desk does not run it.
Scene and node setup
Create World Node2D root with Player (C-BODY), three Coin instances (C-PICKUP), and CanvasLayer HUD > Label named Score plus Button named Restart (text Restart, position 500,10). Root and parents unscaled. Name coins Coin1, Coin2, Coin3. Place them at (250,100),(380,220),(520,100). Player group player. Attach script to World. UI paths and coin names must match exactly. Connect nothing else in the editor. Label at (10,10).
extends Node2D
var score: int = 0
var playing: bool = true
@onready var score_label: Label = $HUD/Score
func _ready() -> void:
$HUD/Restart.pressed.connect(_restart)
for coin in [$Coin1, $Coin2, $Coin3]:
coin.collected.connect(_on_collected)
_refresh()
func _on_collected(points: int) -> void:
if not playing:
return
score += points
if score >= 3:
playing = false
$Player.set_physics_process(false)
_refresh()
func _refresh() -> void:
score_label.text = "Score: %d / 3" % score
if not playing:
score_label.text += " — Orchard complete!"
func _restart() -> void:
get_tree().reload_current_scene()
Checks to run in the editor
- Collect three coins: score is 3 and a completion message appears.
- Restart recreates three coins and score is zero.
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.
Complete progress and end-state feedback — evidence task
- 1. Finish progress, ending text and post-ending event guards.
- 2. Compare internal and visible state at three milestones.
Deliverable. Feedback-complete checkpoint and milestone comparison.
Acceptance checks
- VGC-L154-T1. HUD matches data at all milestones.
- VGC-L154-T2. Events after ending cannot change the completed result.
Understanding question. Why stop a timer or gate its callback after completion?
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. Work on one task-board item at a time and checkpoint after each passing test. Do not expand the room count yet. Start with the first assigned task and re-run its acceptance test before adding the remaining feature.
Optional extra. Add a harmless alternate input or optional route after required mechanics pass. Document one changed parameter, your prediction, and the observed effect; optional, not required for completion.
- Your first 2D game
Free public tutorial; no account; external asset download is optional, not used by this course.
· Opening this link does not submit the lesson.
Name ____________________ Date ____________________