2
파이 게임으로 곡면의 중심을 잡는 데 문제가 있습니다. 다른 서페이스에 배치하려고 할 때 기본적으로 서페이스의 왼쪽 위 모퉁이입니다.pygame에서 파이썬으로 곡면의 중심을 얻는 방법.
내가 무슨 뜻인지 설명하기 위해 짧은 프로그램을 작성했습니다.
import pygame
WHITE = (255, 255, 255)
pygame.init()
#creating a test screen
screen = pygame.display.set_mode((500, 500), pygame.RESIZABLE)
#creating the canvas
game_canvas = screen.copy()
game_canvas.fill(WHITE)
#drawing the canvas onto screen with coords 50, 50 (tho its using the upper left of game_canvas)
screen.blit(pygame.transform.scale(game_canvas, (200, 200)), (50, 50))
pygame.display.flip()
#you can ignore this part.. just making the program not freeze on you if you try to run it
import sys
clock = pygame.time.Clock()
while True:
delta_time = clock.tick(60)/1000
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
이 프로그램는 좌표 (50), (50)의 화면 (디스플레이)에서 200 (200)에 의해 흰색 game_canvas을 그릴하지만 대신 좌표 50, 50에 game_canvas의 중심을 사용하는 것을 실행합니다. 왼쪽 상단은 50, 50입니다.
그래서 game_canvas의 중심을 사용하여 50, 50 또는 기타 지정된 좌표에 배치 할 수 있습니까?
고마워요, 이것은 저를 괴롭 혔습니다. 그러나이 작업을 수행하기 위해 화면의 사본에서 내 game_canvas를 자신의 파이 게임 표면으로 변경하고 블리트의 측면에서 내 변형을 수행했습니다. 이제 잘됩니다. –