|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
pg.init()
ball_image = 'ball.png'
bg_image = 'background.png'
running = True
bg_size = width,height = 1024 , 600
screen = pg.display.set_mode(bg_size)
pg.display.set_caption('Play the ball !')
background = pg.image.load(ball_image).convert_alpha
balls = []
for i in range(5):
position = randint(0,width-64),randint(0,height-64)
speed = [randint(-10,10),randint(-10,10)]
ball = Ball(ball_image,position,speed)
balls.append(ball)
while running:
for event in pg.event.get():
if event.type == QUIT:
sys.exit()
screen.fill((255,255,255))
screen.blit(background,(0,0))
for each in balls:
screen.blit(each.image,each.rect)
Traceback (most recent call last):
File "C:\Users\ASUS\Desktop\main.py", line 53, in <module>
main()
File "C:\Users\ASUS\Desktop\main.py", line 43, in main
screen.blit(background,(0,0))
TypeError: argument 1 must be pygame.Surface, not builtin_function_or_method
- def main():
- pg.init()
- ball_image = 'star02.png'
- bg_image = 'backgroudpicture01.jpg'
- running = True
- bg_size = width, height = 1024, 600
- screen = pg.display.set_mode(bg_size)
- pg.display.set_caption('Play the ball !')
- background = pg.image.load(ball_image).convert_alpha()
复制代码
最后这里,你在class里加了括号,这里没加
|
|