불행히도, 파이 게임은 그러한 기능을 제공하지 않습니다. 가장 간단한 방법은 좌표를 변환하는 함수를 사용하고 객체를 그리기 직전에 사용하는 것입니다.
def to_pygame(coords, height):
"""Convert coordinates into pygame coordinates (lower-left => top left)."""
return (coords[0], height - coords[1])
이 좌표를 가지고 height
, 윈도우의 높이 및 coords
, 객체의 왼쪽 상단 모서리를 주어진 도면에 대한 파이 게임의 좌표로 변환합니다. 대신 개체의 왼쪽 하단 모서리를 사용하려면
, 당신은 위의 공식을하고, 객체의 높이를 뺄 수 있습니다
def to_pygame(coords, height, obj_height):
"""Convert an object's coords into pygame coordinates (lower-left of object => top left in pygame coords)."""
return (coords[0], height - coords[1] - obj_height)
을