Video Game Design and Coding · PLECK lesson

PLECK lesson 24 · suggested week 5, day 4

Make feedback readable in a HUD

Objective. Update a Label from state rather than storing state in text.

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.

Area2D signals, groups, exactly-once events and a HUD

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-L023.

The HUD is feedback layered over the game world. A CanvasLayer keeps it separate from world motion. Store score as an integer in the manager, then derive the Label text using formatting. Do not read the visible string to decide whether the player won: changing wording or translation would break the rule. Put the HUD where it does not cover the route. Use both a number and a word or icon so color alone is not the only way to understand progress.

Worked example

A pickup emits collected(1); a manager receives that event and changes one score variable. The label formats that score rather than keeping a second independent total. 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() ```

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

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.

Pocket Orchard starter, as text files. Open the files in Godot on the family computer. This page does not download a zip or run the project.

Make feedback readable in a HUD — evidence task

  1. 1. Add the Score label at (10,10) and format Score: n / 3.
  2. 2. Increase its font size and move one route obstacle if HUD overlap occurs.

Deliverable. Project checkpoint and HUD screenshot at scores zero and two.

Acceptance checks

Understanding question. Which is authoritative: score or the label text?

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 one coin and one player in a blank World. Confirm the group and mask before adding a score label. Start with the first assigned task and re-run its acceptance test before adding the remaining feature.

Optional extra. Add a second pickup value using the same signal instead of duplicating the whole scene. Document one changed parameter, your prediction, and the observed effect; optional, not required for completion.

Name ____________________ Date ____________________