0
我正在關注PyGame的教程,並且在其中一個教程中我們正在創建一個簡單的Space Invaders遊戲。我有幾個問題。sprite沒有出現在pygame和無效的rectstyle對象
- 宇宙飛船精靈不會顯示在屏幕上,2.我得到一個錯誤。 (下面是詳細介紹)
代碼:
import pygame, sys
from pygame.locals import *
clock = pygame.time.Clock() #framerate
size = x,y=800,600
screen = pygame.display.set_mode((size)) #creates window, with resolution of 1600,900
pygame.mouse.set_visible(0)
ship = pygame.image.load('ship.png')
ship_top = screen.get_height() - ship.get_height() #makes it so ship is in the centre at the bottom
ship_left = screen.get_width()/2 - ship.get_width()/2
while True: #main game loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.fill(0,0,0)
screen.blit(ship,(ship_left,ship_top))
clock.tick(60)
pygame.display.update
錯誤:
Traceback (most recent call last):
File "D:\python_tuts\space_invaders.py", line 24, in <module>
screen.fill(0,0,0)
ValueError: invalid rectstyle object
所以精靈不顯示,我得到這個錯誤。
感謝,