Skip to content

BuyMyBeard/pixi-physics

Repository files navigation

pixi-physics

Physics engine plugin tailored for PixiJS

Live interactive example here. Refer to this for input mapping.

I've taken an interest in 2d physics engines after working on multiple Unity 2d platformers, so I decided to make my own physics engine! I already have a sweet spot for Pixijs as a rendering engine, since I made my first few jam games with it. At heart, it's not a framework, so I wanted to contribute to it by making a plugin that works seemlessly and does all you want a 2d physics engine to do.

I know a few integrations of pre-existing 2d physics engines have already been done with PixiJS, like Matterjs and Box2D, but I don't like the idea of having to sync the renderer and the physics simulation. Making the physics use PixiJS's DisplayObject transform is a lot more intuitive overall, and avoids problems where the 2 are out of sync, while also probably being faster and more memory efficient (don't quote me, I didn't benchmark it).

There are also a few things I'm unhappy about, like those engines not being maintained and Matter.js's circles not being real circles, but overall it's mainly just an excuse to program something myself for funsies.

Video examples of physics engine in action

Rotational physics and friction in action

pixi.physics.-.Google.Chrome.2023-08-08.10-45-07.mp4

1000 particle simulation with perfectly elastic collisions

pixi.physics.-.Google.Chrome.2023-08-09.13-48-53.mp4

Backlog

  • Stacking stability tuning M
  • Raycast M
  • Documentation M
  • Body Factory S
  • Capsule bodies S
  • Concave polygons C
  • Joints C
  • Soft Bodies W
  • Ellipse Bodies W

Done

  • Circle bodies
  • Broad phase (Sweep and Prune)
  • Polygon bodies
  • Collision detection
  • Collision response
  • Collision resolution
  • Forces and impulses
  • Friction
  • Bounciness
  • onCollisionEnter, onCollisionStay, onCollisionExit events
  • Static bodies
  • lockX, lockY, lockRotation
  • Layer system

About

Attempt at creating a physics engine plugin for pixijs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages