Marble Lab 2D
Try itI recently discovered that a lot of people like watching videos of marble races, even pure simulated marble races are quite popular. Marble Lab 2D is a game that allows users to build custom tracks and then watch the simulation of their creation. It has sharing features, so if someone builds a track they are happy with, they can share it with others. Users can view tracks made by others and vote for the ones they like the most.
Like my other experimental projects, the only front end dependencies were kept minimal. The only library imported for this project is a web assembly implementation of the Box 2D physics engine. All artwork is done through drawing directly to an HTML canvas using the browser's canvas API.
The part that was expectedly challenging was the creation of the free form level designer. The functionality for adding, reshaping, and moving the various shapes, and configuring their physics properties required some careful planning.
The part that was unexpectedly challenging was getting the "marbles" to roll smoothly down a curved line. I started with the rapier.js physics engine, but consistently ran into issues with "ghost collisions" when trying to get a marble to roll down a curved line. Smooth rolling curved surfaces was a requirement though, because I wanted people to be able to make neat loops and curved ramps. I really enjoyed working with the Rapier physics engine, and I am going to use it for other projects in the future (it is very good), but I was forced to move to the Box 2D Physics engine, which provides the option to chain shapes (as long as they are static). Once I adopted this approach the smooth rolling over curves worked, and high speed loops could be created without the marbles randomly jittering or springing off tangential to the line.