if trying to move both vertically and horizontally, allow movement in the directions that do not cause collision