Video Game Design and Coding · PLECK lesson

PLECK lesson 73 · suggested week 15, day 3

Explain the motion model without memorizing code

Objective. Trace one physics step in words and numbers.

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.

Difficulty curves, debugging, observation and a completed artifact

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: Paper and pencil or a private text document, Local course folder and prior checkpoint, No paid assets or public account required.

Comes after VGC-L072.

Understanding code includes predicting a step. Suppose horizontal input is right, speed is 160, current y velocity is -100, gravity is 900 and delta is 0.02 while airborne. The next horizontal velocity is 160 and vertical velocity becomes -82 before move_and_slide. The character is still rising because y velocity remains negative. Write this trace in a table. Do not multiply the final velocity by delta before handing it to move_and_slide. Explain which operation actually resolves contact with floors and walls.

Worked example

For a repeated route test, keep controls and start position fixed. A table of attempts helps distinguish a consistently hard landing from a one-time input mistake. Scaffold C-PLATFORM — A gravity-and-jump platform player Setup: CharacterBody2D root Player, child CollisionShape2D RectangleShape2D size (24,32), no scale changes. Layer 1 mask 2. StaticBody2D floor layer 2 mask 1 with rectangular collider. Add Input Map move_left, move_right and jump bound to Space. Place player above floor, not intersecting it. Coordinates use positive y downward. Attach script to Player. ```gdscript extends CharacterBody2D @export var speed: float = 160.0 @export var gravity: float = 900.0 @export var jump_speed: float = 340.0 func _draw() -> void: draw_rect(Rect2(-12, -16, 24, 32), Color.SKY_BLUE) draw_line(Vector2(-8, -4), Vector2(8, -4), Color.BLACK, 2.0) func _physics_process(delta: float) -> void: velocity.x = Input.get_axis("move_left", "move_right") * speed if not is_on_floor(): velocity.y += gravity * delta if Input.is_action_just_pressed("jump") and is_on_floor(): velocity.y = -jump_speed move_and_slide() ```

A gravity-and-jump platform player

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

Scene and node setup

CharacterBody2D root Player, child CollisionShape2D RectangleShape2D size (24,32), no scale changes. Layer 1 mask 2. StaticBody2D floor layer 2 mask 1 with rectangular collider. Add Input Map move_left, move_right and jump bound to Space. Place player above floor, not intersecting it. Coordinates use positive y downward. Attach script to Player.

extends CharacterBody2D
@export var speed: float = 160.0
@export var gravity: float = 900.0
@export var jump_speed: float = 340.0
func _draw() -> void:
    draw_rect(Rect2(-12, -16, 24, 32), Color.SKY_BLUE)
    draw_line(Vector2(-8, -4), Vector2(8, -4), Color.BLACK, 2.0)
func _physics_process(delta: float) -> void:
    velocity.x = Input.get_axis("move_left", "move_right") * speed
    if not is_on_floor():
        velocity.y += gravity * delta
    if Input.is_action_just_pressed("jump") and is_on_floor():
        velocity.y = -jump_speed
    move_and_slide()

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.

Explain the motion model without memorizing code — evidence task

  1. 1. Trace the supplied step and a second step with starting y velocity 20.
  2. 2. Annotate where input, acceleration and collision resolution occur.

Deliverable. Two-step table and annotated movement script.

Acceptance checks

Understanding question. Is y velocity -82 rising or falling in this coordinate system?

Submit readable text or photos/scans of each numbered design page. Audio explanation may supplement a diagram or text, not replace requested artifacts.

If this is still shaky. Use the three-jump route and one checkpoint as the minimum game. Remove optional hazards until required tests pass. Start with the first assigned task and re-run its acceptance test before adding the remaining feature.

Optional extra. Create a second optional route using the same movement code. Document one changed parameter, your prediction, and the observed effect; optional, not required for completion.

Name ____________________ Date ____________________