Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

vonWolfehaus/von-physics

Repository files navigation

"Arcade"-style game physics

screenshot

After implementing far too many collision detection algorithms in my various experiments and games since 2009, I've decided enough is enough and compiled this tiny library of just the raw math behind collision detection and physical response.

It is meant to provide the minimal (and in most cases sufficient) system necessary for creating high performance real-time applications with dynamic objects interacting with each other.

Features:

  • Most efficient techniques for performant detection and response for axis-aligned 2D and 3D boxes and radial colliders
  • Mass and restitution only (sometimes less is more)
  • Continuous collision detection for 2D and 3D radial colliders
  • Signal dispatch on collision that provides collided entity and manifold describing the collision
  • "World" class with friction, gravity, and boundaries (infinity works too)
  • Memory-efficient broadphase (2D static grid)

Bonus 2D and 3D wandering behavior in the examples.

Note: If you use continuous detection and the broadphase grid, it can still miss some collisions because it doesn't check cells that the collider will be in after velocity is applied (it only uses position).

Full engines with readable code

These are engines that have fancy things like rotational torque, joints, and so on. If you want a "physics-based" game, use one of these instead. Or just use Unity, let's be honest. The web is terrible for games, if only because you can't safeguard your assets. Great for prototyping though, with the right tools 😉

Resources

Other tricks