Skip to content

Module 4 — Gameplay systems

Goal

Turn art + 3D rendering into a small game: move, animate, follow-cam, collide, spawn entities, and switch title / play / pause / win.

Prerequisites

  • Modules 0–3 (especially Tiny3D load + asset lab)
  • Comfortable reading multi-file C

Lessons

LessonSkill
L26 — MoveCamera-relative stick movement
L27 — Anim driveIdle/walk blend from speed
L28 — Follow camSoft third-person camera
L29 — CollisionSphere pickups + bounds
L30 — EntitiesSpawn table + entity loop
L31 — Game stateTitle / play / pause / win
Toy CoveCheckpoint mini-game

Shared helper

common/include/ng_game.h — deadzone, time, lerp, angle lerp, clamp.

Patterns that must match the ROMs

TopicCourse convention
Stick-upInto the screen (look on XZ) — see L26
Move basis (L28+)Lagged eye→player, not player yaw; camYaw only from C-buttons
Soft wallBox clamp (±5.5), not radial
Snake facingModel yaw -yaw (mesh faces −Z)
Model matricespush → draw → pop (not matrix_set over the camera)
Skinned playert3d_skeleton_use then t3d_model_draw_skinned
Island / snake / shard scales~0.032 / 0.02 / 0.02 on course island (L27 sample map uses different units)
VI / clearFILTERS_RESAMPLE + opaque clear (0xFF) — no AA edge flicker
Audio (Module 5)audio_init(48000) with Opus wav64

Full checklist: Scale & conventions.

Build

bash
source scripts/env.sh
make l26 l27 l28 l29 l30 l31
make -C lessons/m4-toy-cove

Start: L26 — Move.

N64 Educator v1.2.2 — libdragon + Tiny3D · branch master