Bash.tv → GitHub → itch.io

Validate physics and collision behavior so objects never pass through walls, get stuck, or collide wrong. Automated sweeps of speeds, angles and frame rates that detect tunneling and sticking, edge-case tests for overlap functions (touching edges, corners, zero size), corner and seam cases in tilemaps, one-way platforms, slopes, moving platforms, stacking order, hitbox vs sprite alignment with ...

Download skill (.zip) Files on GitHub

Game collision testing

1. Automated sweep (node, no browser)

Use the game’s real step and collision code (keep it in pure modules: game-architecture):

import { sweep, aabbEdgeCases } from "./collision-sweep.mjs";       // <skill>/assets
import { stepPlayer } from "../src/physics.js";
const r = sweep({
  makeWorld: () => makeTestLevel(),                                  // a wall 8 px thick
  makeBody: (x, y, vx, vy) => ({ x, y, w: 20, h: 28, vx, vy }),
  step: (world, body, dt) => stepPlayer(world, body, dt),
  overlaps: (world, body) => world.solidAt(body),
  passed: (world, body) => body.x > 140,                             // ended up beyond the wall?
  start: { x: 40, y: 90 }, target: { x: 104, y: 100 },
  speeds: [100, 600, 2000, 6000], angles: 15, dts: [1 / 30, 1 / 60, 1 / 144],
});
console.log(r.summary);           // "all 180 trials passed"  or  "27/180 trials failed (27 tunneled); lowest failing speed 6000"
console.log(aabbEdgeCases(overlaps));   // touching edges / corners must NOT count as overlap (or be consistent)

Tested: a naive “move then push back” fails at 6000 px/s; game-physics’ moveAndSlide (substeps) passes all trials. Set the speeds to the game’s real maximum (dash, falling at terminal speed, bullets) plus a margin.

2. Cases to cover

Case What goes wrong
High speed vs thin walls Tunneling → substeps, swept AABB, raycasts for bullets
Low frame rate (dt 1/30, or a spike) Tunneling or different jump heights → fixed step + dt cap
Corners and tile seams Snagging on flat floors made of tiles (resolve per axis; merge colliders)
Moving into a corner diagonally Stuck, or wrong axis resolved first
Spawning or resizing inside solids Stuck forever → push out on spawn, check space before growing
One-way platforms Landing from below, dropping through, standing at the edge
Slopes Bouncing down slopes, sliding while standing, stuck at the top seam
Moving platforms Player slides off, gets crushed, jitters (move the rider with the platform)
Many objects at once Order-dependent results, pushing through each other in a pile
Hit detection Bullets hit two enemies in one frame, or hits on the frame an enemy dies
Map edges Leaving the map (add solid bounds or kill planes)

3. See the hitboxes

Debug overlay (toggle with a key): draw every collider outline, contact normals and velocity vectors. Check they match the art (player hitbox slightly smaller than the sprite is good). Screenshot it (playwright-game-testing) at the problem spot.

4. In-game checks

With the debug handle, place the player and test in the browser: __game.player.x = 95; __game.player.vx = 3000, step a few frames, check the position. Add these as playtest steps so they run as a regression test.

Report

“Collision sweep: 180 trials at up to 6000 px/s and 30–144 fps, 0 tunneling, 0 stuck. Edge cases pass. Fixed: spawning inside the wall on level 3 (now pushed out).”