Simple physics simulation using pure JS