飞翔的小鸟素材
import pygame
from pygame.locals import *
from sys import exit
# 变量
path = 'resources/images/'
index = 0
y = 300
color1 = (100,200,100)
rects1 = [200,0,60,250]
# 初始化
pygame.init()
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption('flappy bird')
bg = pygame.image.load(path + 'background.png') # 加载图片
bg = pygame.transform.smoothscale(bg, (800, 600))# 缩放图片大小为800*600
# 运行时
while True:
for event in pygame.event.get():
if event.type == QUIT:
exit()
screen.blit(bg, (0, 0)) # 在0,0位置绘制加载好的背景图片
pygame.draw.rect(screen,color1,rects1)
pygame.display.update()