代码
import sys
import pygame
pygame.init()
screen = pygame.display.set_mode((600, 480), 0, 32)
pygame.display.set_caption('my game')
screen.fill('white') #根据名字获取颜色
# 创建一个50*50的surface, 并优化显示, 填充粉色
face = pygame.Surface((50, 50), flags=pygame.HWSURFACE)
face.fill(color='pink')
# 创建一个image surface.
img = pygame.image.load('star.png')
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
screen.blit(face, (100, 100)) #将face叠加到主Surface上面.
screen.blit(img , (125, 120)) #将img叠加到主Surface和face上面.
pygame.display.flip()
运行结果: