代码
import sys
import pygame
pygame.init()
screen = pygame.display.set_mode((600, 480), 0, 32)
pygame.display.set_caption('my game')
screen.fill('white') #根据名字获取颜色
# 创建image surface.
img0 = pygame.image.load('star.png') # 原始img
img1 = pygame.transform.scale(img0, (78, 78)) # 更改图片大小
img2 = pygame.transform.rotate(img0, 45) # 旋转图片角度
img3 = pygame.transform.rotozoom(img0, 45, 1.5) # 旋转45度, 并放大1.5倍
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
screen.blit(img0, (100, 100)) #将img0叠加到主Surface上面.
screen.blit(img1, (200, 100)) #将img1叠加到主Surface上面.
screen.blit(img2, (300, 100)) #将img2叠加到主Surface上面.
screen.blit(img3, (400, 100)) #将img3叠加到主Surface上面.
pygame.display.flip()
运行结果: