我正在試着製作一個圓形動畫,並希望它在窗口內反彈,只是爲了練習。我被告知pygame.draw.rect
返回Rect
對象,但是,我做了這個小代碼,看看它是否工作,並沒有。圓圈不像預期的那樣每次迭代向下移動一個像素。可能是什麼問題?pygame圓圈動畫
import pygame, sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((600, 500), 0, 32)
mainClock = pygame.time.Clock()
screen.lock()
circleRect = pygame.draw.circle(screen, (255, 255, 255), (100, 200), 40)
screen.unlock()
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
circleRect.top += 1
pygame.display.update()
mainClock.tick(40)
由於這只是pygame教程中顯示的第一項任務,我建議你閱讀它。 – msw