JavaScript 2D Collision detection framework