Rushed attempt to write a 2D physics engine in JS