使用pygame 写一个飞机大战游戏 但是只写出了一个飞机界面
import pygame
from color import Color
from add_picture import add_pic
from add_picture import add_text
pygame.init()
window = pygame.display.set_mode((400, 600)) #设置屏幕大小
window.fill((255, 255, 255)) #填充颜色
# =======================================================================
image_obj1 = pygame.image.load('file/background.png') # 标题
image_obj2 = pygame.image.load('file/background.png') # 标题
# image_obj3 = pygame.image.load('file/game_loading2.png') # 标题
# # image_obj3 = ('file/game_loading2.png', (180, 360), angle=90, scale=0.8)
y1 = 0
y2 = -880
while True:
window.blit(image_obj2, (0, y2)) # 渲染位置
pygame.display.update() # 重新显示
y2 += 1
if y2 == 0:
y2 = -880
window.blit(image_obj1, (0, y1))# 渲染位置
pygame.display.update() # 重新显示
y1 += 1
if y1 == 880:
y1 = 0
# window.blit(image_obj3, (180, 360)) # 渲染位置
# pygame.display.update() # 重新显示
add_pic('file/title.png', (93, 100), scale=0.5) # 标题
add_pic('file/enemy1_5.png', (80, 200), scale=0.8) # 敌机1
add_pic('file/enemy1_5.png', (320, 260), scale=0.8) # 敌机2
add_pic('file/enemy2.png', (300, 40), scale=0.6) # 敌机3
add_pic('file/game_resume_nor.png', (100, 450), scale=0.8) # 开始按钮
pygame.draw.rect(window, (190, 190, 190), (90, 450, 220, 40)) # 创建矩形边框
add_text('file/aa.ttf', 30, 'Start Game', (255, 0, 0), (140, 450))
pygame.display.flip()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
网友评论