1
我正在學習pygame,並且我剛剛輸入了幾條基本線來嘗試在我的窗口之間移動一個球,但是在顯示圖像之後,窗口將會凍結。Pygame Not Responding
import pygame
pygame.init()
screen = pygame.display.set_mode((640, 480))
ball = pygame.image.load("ball.png").convert()
ball_rect = ball.get_rect()
white = (255,255,255)
frames = 100
for x in range(frames):
screen.blit(ball, ball_rect) # display player
ball_rect.move(2, 2) # move player
pygame.display.update()
pygame.time.delay(100)
screen.fill(white) # erase player
更好的實例化[時鐘](http://www.pygame.org/ docs/ref/time.html#pygame.time.Clock)'clock = pygame.time.Clock()',然後每幀調用'clock.tick(desired_frame_rate)'來限制幀速率。 'pygame.time.delay'使遊戲無響應。 – skrx
感謝您的幫助。有效。 – Matthew