Player movement that feels tight in platformers, top-down games and grid games. Walking and running with acceleration and friction, jumping with coyote time, jump buffering and variable height, faster falling, air control, wall slide and wall jump, double jump, dash, ladders and one-way platforms, normalized 8-direction movement, tile-by-tile grid movement with input queueing, and frame-rate in...
Download skill (.zip) Files on GitHubPlayer movement
Drop-in: assets/movement.js (15 tests: same jump height at 30, 60 and 144 fps; short hops; coyote time; jump buffer; wall
slide and wall jump; dash; normalized diagonals; grid queueing). Collision comes from game-physics moveAndSlide.
import { platformer, PLATFORMER, topDown, TOPDOWN, GridMover } from "./core/movement.js";
import { moveAndSlide } from "./core/physics.js";
const cfg = { ...PLATFORMER, ...config.player }; // tune in config.js
const collide = (b, dx, dy) => moveAndSlide(b, dx, dy, level.isSolid, TILE);
// fixed step:
platformer(player, {
x: input.stick().x, jump: input.down("jump"), jumpPressed: input.pressed("jump"), dashPressed: input.pressed("dash"),
}, cfg, dt, collide);
Pick the controller
| Game | Controller | Key numbers |
|---|---|---|
| Platformer | platformer |
maxSpeed 220–300, jump 550–700, gravity 1600–2200, fallMult 1.4–2 |
| Top-down action / twin-stick | topDown |
maxSpeed 180–260, accel high (snappy) |
| Puzzle, RPG, roguelike on tiles | GridMover |
6–10 tiles/s |
| Vehicles | see racing-game-development |
What makes it feel good
- Accelerate in ~0.1 s, stop a bit faster. Instant = stiff, slow = floaty or icy.
- Coyote time (~0.1 s) and jump buffer (~0.12 s): the game forgives being a few frames early or late.
- Variable jump height: releasing jump cuts upward speed (
jumpCut). Fall faster than you rise (fallMult). - Air control a bit lower than ground control, but not zero.
- Wall jumps push away from the wall. A short wall stick (0.1 s) stops you sliding off when pressing away.
- Dash: short (0.12–0.2 s), fixed direction, a cooldown, optional invincibility.
- Grid games: queue the next direction pressed near the end of a step, so holding a direction moves smoothly.
Extras
- One-way platforms / drop-through, slopes, moving platforms: game-physics.
- Ladders: a ladder zone switches to vertical
topDown-style movement with gravity off; jump or move sideways off the top to exit. - Double jump:
airJumps: 1. Ground pound: big downward speed + a landing shake. - Touch controls: mobile-game-controls (floating stick + jump button). Feed the stick’s x into
x.
Check
Play at different frame rates (the controllers use dt; physics should use a fixed step), try every edge (corners, ledges, under ceilings), then tune one number at a time (game-mechanics). Record final values in the design doc.