Collision Detection & Response in JavaScript