Video Game Design and Coding · PLECK lesson

PLECK lesson 6 · suggested week 2, day 1

Print a first event

Objective. Recognize _ready as a one-time scene-start event.

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.

Values, types, expressions, branches and repeatable experiments

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

Godot nodes can have scripts. The first line extends Node says which node behavior this script extends. A variable stores a value, while a function groups steps. In C-HELLO, _ready runs after the node enters the scene tree and its children are ready. Indentation puts the increment and print inside that function. Running the scene again creates a new node and resets its variable. Output is a diagnostic tool; it is not automatically visible to a player in an exported game.

Worked example

A counter lab can store parcels as an int and route_title as a String. print exposes intermediate values; a function such as double_points(n) returns n*2 without needing any artwork. Scaffold C-HELLO — An observable first script Setup: Create a Node scene, name root Lab, attach lab.gd. Save as lab.tscn. Run current scene (editor clapboard/Run Current Scene). Output panel shows print output. All unindented lines belong to the script and indented lines belong to the function. ```gdscript extends Node var deliveries: int = 0 func _ready() -> void: deliveries += 1 print("Deliveries: ", deliveries) ```

An observable first script

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

Scene and node setup

Create a Node scene, name root Lab, attach lab.gd. Save as lab.tscn. Run current scene (editor clapboard/Run Current Scene). Output panel shows print output. All unindented lines belong to the script and indented lines belong to the function.

extends Node
var deliveries: int = 0
func _ready() -> void:
    deliveries += 1
    print("Deliveries: ", deliveries)

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.

Print a first event — evidence task

  1. 1. Attach C-HELLO to Lab and run twice, stopping between runs.
  2. 2. Change the printed label and initial value to 4, then predict the new output.

Deliverable. lab.gd, scene and a predicted/observed output note.

Acceptance checks

Understanding question. Why does the second fresh run not print 2?

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. Return to C-HELLO and change one value per run. Write the expected output before running. Start with the first assigned task and re-run its acceptance test before adding the remaining feature.

Optional extra. Create another small numeric example and predict the result without executing it first. Document one changed parameter, your prediction, and the observed effect; optional, not required for completion.

Name ____________________ Date ____________________