| name | machin-game-demo-player |
| description | Build, run, and modify machin-game-demo-player — a first-person 3D playground with walking, jumping, platform stepping, object pushing, and walk/fly camera toggle. Use when working on this repo or as the reference for first-person player controllers and interactive physics in machin. |
machin-game-demo-player
A first-person 3D playground — walk on platforms, jump between them, push objects around. Toggle walk/fly with F. Written in machin (MFL) via raylib's C FFI.
Shared game-dev setup, the FFI surface, and gotchas live in the canonical machin-gamedev skill. This file covers the specifics of this demo.
Build & run
./build.sh
./machin-game-demo-player
Needs machin v0.48.0+, a C compiler, raylib, and a display.
Architecture
Player data (local variables in main)
px, py, pz — world position (camera at (px, py + EYE_H, pz))
pvx, pvy, pvz — velocity
yaw, pitch — look direction
grounded — 1 if on a surface
walk_mode — 1 = walking, 0 = flying
Walk-mode loop (per frame)
- Mouse look: yaw/pitch accumulate from
GetMouseDelta() (clamped pitch ±80°).
- Input direction: WASD produces a horizontal direction vector from
sin(yaw)/cos(yaw). Normalized and scaled by speed.
- Acceleration:
vel += (target - vel) × clamp(accel·dt, 0, 1) — smooth interpolation toward the input direction, frame-rate independent.