Matter.js Arcade Games

After handcrafting my own physics engine (for the shoot'em up game Axiom and an isometric RPG) I began to understand why using an existing library might be a better choice.

Some parts that I built worked well enough. I was able to implement collision detection and resolution (even for rotated entities). However some of the more complex concepts, like torque and high velocity motion were a real challenge. I was spending weeks reading game development articles and trying to fix my system when I really wanted to be building games.

To return to the work I was interested in, and to have less buggy games, I decided to include an open-source physics engine.

I picked Matter.js for a few reasons, but primarily it was easy to make it run lock-step with my existing engine.

Time to learn the ropes

To get my feet wet in this new engine's waters I decided to build clones of some classic arcade games with simple mechanics.

Sorta space invaders

My first iteration of Space Invaders kept the entities bound to their physics objects. This had interesting results, and while it isn't faithful to the original game it's an interesting mechanic that I might revisit.

In an effort to be closer to the original game, I updated the code to only use the physics objects for collision detection events. The actual position for the entities was specified with the game logic.

Almost Asteroids

Asteroids was impersonated for fun. Now with crates.

Published: August 13, 2018

Categories: gamedev, webdev