Video Game Design and Coding

PLECK lesson 12 · suggested week 3, day 2

Instance a scene twice

Objective. Distinguish a shared scene definition from individual instances.

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.

A visible actor, reusable scenes and measured movement

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

An instance is a use of a saved scene. Create a World Node2D scene, then drag Actor.tscn into it twice. The two actors share the saved shape recipe but have separate positions. Renaming an instance or changing its transform does not require duplicating its script. Editing the source Actor scene updates both when they use the same source. Reuse prevents slightly different copies of the same behavior from drifting apart during later fixes.

Worked example

A circle drawn at Vector2.ZERO belongs to its Node2D origin. If its parent is at (100,80) and its local position is (20,10), its world origin is (120,90) when neither parent is rotated or scaled. Scaffold C-DRAW — Draw an original geometric actor Setup: Create Node2D root Actor. Attach actor.gd. Save Actor.tscn. A draw command uses coordinates relative to Actor. Set its Position to (200,150) in the Inspector. Change the blue color or white marker to make original art. No imported artwork is needed. ```gdscript extends Node2D func _draw() -> void: draw_circle(Vector2.ZERO, 14.0, Color(0.15, 0.5, 0.9)) draw_line(Vector2(-8, 0), Vector2(8, 0), Color.WHITE, 3.0) ```

Draw an original geometric actor

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

Scene and node setup

Create Node2D root Actor. Attach actor.gd. Save Actor.tscn. A draw command uses coordinates relative to Actor. Set its Position to (200,150) in the Inspector. Change the blue color or white marker to make original art. No imported artwork is needed.

extends Node2D
func _draw() -> void:
    draw_circle(Vector2.ZERO, 14.0, Color(0.15, 0.5, 0.9))
    draw_line(Vector2(-8, 0), Vector2(8, 0), Color.WHITE, 3.0)

Checks to run in the editor

  • Actor is visible centered at its position.
  • Move root: both circle and marker move together.

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.

Instance a scene twice — evidence task

  1. 1. Create two actor instances named Courier and Marker at distinct positions.
  2. 2. Change the source drawing’s radius once and observe both.

Deliverable. World and Actor project checkpoint plus before/after screenshot.

Acceptance checks

  • VGC-L012-T1. Two independent positions persist when reopening World.
  • VGC-L012-T2. A source drawing change appears in both instances.

Understanding question. Which change should be made on the source scene if every courier needs it?

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 a 640 by 360 viewport, one unscaled Node2D and the C-DRAW recipe before adding movement. Start with the first assigned task and re-run its acceptance test before adding the remaining feature.

Optional extra. Add a second independently colored actor without changing the first actor’s script. Document one changed parameter, your prediction, and the observed effect; optional, not required for completion.

Turn in typed notes and a JPEG, PNG, or WebP screenshot. One https address is stored as text and is not opened, extracted, or run. An MP3, WAV, M4A, MP4, or WebM file up to 4 MB can show a demo. The demo does not replace editable source. Zip and code files are refused. If there is no private link, keep the project on the family computer and review the code in person.

This is a preview. A parent assigns the lesson and chooses the due date after the student is enrolled. The answer key is not on this page.

Print this lesson