Video Game Design and Coding

PLECK lesson 43 · suggested week 9, day 3

Tune difficulty as data

Objective. Expose a small set of parameters and compare presets.

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.

Fair randomization, difficulty, accessibility and assessment

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

Difficulty becomes manageable when named parameters control it. Create Gentle and Standard presets for hazard speed, spawn interval and recovery duration. Keep the same core rules and give the player a clear choice before starting. A gentle mode should not shame the player or hide essential learning. Compare two thirty-second runs per preset using survival time and perceived control notes. Do not silently adapt difficulty based on personal information or collect telemetry from other players.

Worked example

An incoming three-lane wave blocks left and center but leaves right clear. Randomly choosing among valid two-lane combinations creates variation while preserving an escape route. Scaffold C-TIMER — Timer-based spawning with a hard cap Setup: World Node2D root contains Node2D Hazards and Timer SpawnTimer: wait_time 1.2, autostart On, one_shot Off. Hazard scene root Area2D has a CircleShape2D radius 12 and C-HAZARD. Attach script to World and drag Hazard.tscn into hazard_scene Inspector field. Set viewport 640x360. Name Hazards group not needed. This script is a separate lab; merge its _ready into an existing manager rather than declaring a second _ready. ```gdscript extends Node2D @export var hazard_scene: PackedScene @export var spawn_limit: int = 12 func _ready() -> void: $SpawnTimer.timeout.connect(_spawn) func _spawn() -> void: if hazard_scene == null or $Hazards.get_child_count() >= spawn_limit: return var hazard := hazard_scene.instantiate() as Area2D $Hazards.add_child(hazard) hazard.position = Vector2(randf_range(20.0, 620.0), -20.0) ``` 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] ```

Timer-based spawning with a hard cap

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

Scene and node setup

World Node2D root contains Node2D Hazards and Timer SpawnTimer: wait_time 1.2, autostart On, one_shot Off. Hazard scene root Area2D has a CircleShape2D radius 12 and C-HAZARD. Attach script to World and drag Hazard.tscn into hazard_scene Inspector field. Set viewport 640x360. Name Hazards group not needed. This script is a separate lab; merge its _ready into an existing manager rather than declaring a second _ready.

extends Node2D
@export var hazard_scene: PackedScene
@export var spawn_limit: int = 12
func _ready() -> void:
    $SpawnTimer.timeout.connect(_spawn)
func _spawn() -> void:
    if hazard_scene == null or $Hazards.get_child_count() >= spawn_limit:
        return
    var hazard := hazard_scene.instantiate() as Area2D
    $Hazards.add_child(hazard)
    hazard.position = Vector2(randf_range(20.0, 620.0), -20.0)

Checks to run in the editor

  • One object appears about each 1.2 seconds.
  • At most 12 hazards exist, even during a long run.

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.

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.

Tune difficulty as data — evidence task

  1. 1. Implement two documented parameter presets selected at Title.
  2. 2. Run two trials of each and recommend the default.

Deliverable. Preset table, four trials and project checkpoint.

Acceptance checks

  • VGC-L043-T1. Selected preset applies before the first hazard.
  • VGC-L043-T2. Restart preserves or clearly reselects the documented mode.

Understanding question. Why should a preset apply before spawning starts?

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. Tune just hazard speed and spawn interval on a copied project. Use fixed test runs before adding more mechanics. Start with the first assigned task and re-run its acceptance test before adding the remaining feature.

Optional extra. Offer an optional challenge mode while retaining a gentle default. 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.

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

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