phaser-sat-example icon indicating copy to clipboard operation
phaser-sat-example copied to clipboard

An experiment that uses sat-js with Phaser.

Phaser SAT Example

An example of using the Separating Axis Theorem for collision handling with Phaser.

Check it out for yourself here!

PhaserSat.js is a heavily commented Phaser scene that puts all of this together.

A screenshot of the Phaser SAT example in action

I put this together because I'm terrible at maths and wanted to learn how to perform collision detection and response against sloped tiles. I wanted something like this from a fantastic tutorial by Metanet.

Even though Phaser has its Ninja Physics engine, which is ported from the very examples linked above, I wanted to see if it could be done more concisely.

In the end was able to achieve this thanks to the awesome SAT.js library and this very handy tutorial.

Installation

Install NPM, install Bower, and then install the Bower dependencies.

npm install -g bower
bower install

Open up index.html in your browser!

Controls

WASD to move.