0
파이 게임에 대한 지침서를 따르고 있으며 간단한 스페이스 인베이더 게임을 작성 중입니다. 나는 몇 가지 문제가있다.파이 게임 및 유효하지 않은 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
그래서 스프라이트가 표시되지 않습니다, 나는 그 오류가 발생합니다. 채우기 방법은 다음과 같습니다
감사합니다,