Fix undefined bug when mouse is outside of canvas and moving the player