其间因为自己打代码不正确,出现了一些问题,然后在网上查了一些基础知识
还有
以下是代码:
#-*-coding:utf-8 -*- import sys import pygame pygame.init() size=width,height=640,540 screen=pygame.display.set_mode(size) color=(0,0,0) ball=pygame.image.load("ball.png") ballrect=ball.get_rect() while True: for event in pygame.event.get(): if event.type==pygame.QUIT: sys.exit() screen.fill(color) screen.blit(ball,ballrect) pygame.display.flip() pygame.quit()
在我失败的时候,还找了大佬的一些图片参考,看看自己是不是打错了代码
然后我的运行结果如下:
另外:记得导入ball的图片ball.png