python大作业:飞机大战代码(大一python程序设计)

发布于 2022-05-24  869 次阅读


飞机大战源码,少许参考https://zhuanlan.zhihu.com/p/452322273,可能目录结构写得比较烂,请见谅。

分析与设计:python大作业:飞机大战分析与设计

basic_Sprite.py

import pygame

screen_Rect = pygame.Rect(0,0,400,700)#游戏的屏幕尺寸
game_Frame_Rate = 120#帧率
enemy_Create = pygame.USEREVENT#制造敌机事件
player_Shot = pygame.USEREVENT + 1#储存子弹事件,主要用于子弹的有限发射优化
fast_Enemy = pygame.USEREVENT + 2#快速敌机事件
boss_Create = pygame.USEREVENT + 3#boss创建事件
boss_Shot = pygame.USEREVENT + 4#boss发射子弹事件
boss_Fire = pygame.USEREVENT + 5#boss发射屏障事件

#最基类
class basicSprite(pygame.sprite.Sprite):
    def __init__(self, filename = "game_Material\\background.jpg", speedRow = 0, speedCol = 0):
        super().__init__()#父类初始化
        self.image = pygame.image.load(filename)#图像初始化
        self.rect = self.image.get_rect()#区域初始化
        self.speedRow = speedRow#横向速度
        self.speedCol = speedCol#纵向速度
    def update(self):#更新图像
        self.rect.y += self.speedCol#移动

background.py

from basic_Sprite import*

#背景类
class background(basicSprite):
    #isSecond:False第一张 True第二张
    def __init__(self, isSecond = False):
        super().__init__("game_Material\\background.jpg")
        self.speedCol = 1#调整速度使其飞机具有向前走的视觉效果
        if isSecond:#将第二张背景图置于第一张的顶部
            self.rect.y = -screen_Rect.height
    
    def update(self):
        super().update()
        if self.rect.y >= screen_Rect.height:#当一张图像走到最末端后,移动到另一张图像的最顶端
            self.rect.y = -screen_Rect.height

player_Plane.py

from basic_Sprite import*
from bullet import*
from fire import*
from boom import*
import pygame

#玩家类
class playerPlane(basicSprite):
    def __init__(self):
        super().__init__("game_Material\\playerPlane.jpg")
        self.rect.x = screen_Rect.width/2 - self.rect.width/2#出生位置
        self.rect.y =  screen_Rect.height - 100#出生位置
        self.bullets = pygame.sprite.Group()#子弹组
        self.fires = pygame.sprite.Group()#屏障组
        self.booms = pygame.sprite.Group()#炸弹组
        self.playLife = 20#生命值
        self.is_Attack = 20#被攻击判断 若大于生命值说明被攻击
        self.timeDelay = 0#被攻击的图像的延迟
        self.bulletStore = 0#子弹储存
    def update(self):
        self.move()#更新位置
        if self.is_Attack > self.playLife:#判断被攻击
            self.image = pygame.image.load("game_Material\\playerDestroyed.jpg").convert_alpha()#被攻击图像显示
            self.timeDelay += 1
        if self.timeDelay == 50:#延迟被攻击图像
            self.image = pygame.image.load("game_Material\\playerPlane.jpg").convert_alpha()#恢复原图像
            self.is_Attack = self.playLife#初始化被攻击判断
            self.timeDelay = 0#初始化延迟判断

    #更新位置
    def move(self):
        self.rect.x += self.speedRow
        self.rect.y += self.speedCol
        if self.rect.x < 0:
            self.rect.x = 0
        elif self.rect.x > screen_Rect.width - self.rect.width:
            self.rect.x = screen_Rect.width - self.rect.width
        if self.rect.y < 0:
            self.rect.y = 0
        elif self.rect.y > screen_Rect.height - self.rect.height:
            self.rect.y = screen_Rect.height - self.rect.height

    #发射子弹
    def attack(self):
        Bullet = bullet()
        Bullet.rect.width -= 3
        Bullet.rect.centerx = self.rect.centerx
        Bullet.rect.centery = self.rect.centery
        self.bullets.add(Bullet)

    #发射屏障
    def Fires(self):    
        Fire = fire()
        Fire.rect.centerx = screen_Rect.centerx
        Fire.rect.y = self.rect.y
        self.fires.add(Fire)

    #发射炸弹    
    def Boom(self):
        Boom = boom()
        Boom.rect.centerx = screen_Rect.centerx
        Boom.rect.centery = screen_Rect.centery
        self.booms.add(Boom)

bullet.py/fire.py/boom.py

#bullet.py
from basic_Sprite import*

#玩家的子弹类
class bullet(basicSprite):
    def __init__(self, filename="game_Material\\bullet.jpg", speedRow=0, speedCol=-6):
        super().__init__(filename, speedRow, speedCol)
    def update(self):
        super().update()
        if self.rect.y < 0:#清除屏幕外的子弹 防止内存溢出
            self.kill()

#fire.py
from basic_Sprite import*

#玩家屏障
class fire(basicSprite):
    def __init__(self, filename="game_Material\\fire.jpg", speedRow=0, speedCol=-1):
        super().__init__(filename, speedRow, speedCol)
    def update(self):
        super().update()
        if self.rect.y < 0:#消除屏幕外的屏障
            self.kill()

#boom.py
from basic_Sprite import*

#炸弹类 玩家E技能
class boom(basicSprite):
    def __init__(self, filename="game_Material\\boom.jpg", speedRow=0, speedCol=0):
        super().__init__(filename, speedRow, speedCol)
        self.timeDelay = 0 #延迟图像的消失,从逻辑上对敌方造成多次伤害
    def update(self):
        super().update()
        self.timeDelay += 1
        if self.timeDelay == 500: #500次循环后消失 每次循环消耗boss10滴血量 共消耗5000血
            self.kill()

enemy.py

from basic_Sprite import*
from bullet import*
import random

#敌机类
class enemy(basicSprite):
    def __init__(self) -> None:
        super().__init__("game_Material\\enemy.jpg")
        self.speedCol = random.randint(2,7)#2-7随机速度
        self.rect.top = 0#在屏幕顶端生成
        self.rect.width -= 2#优化碰撞
        self.rect.height -= 3#优化碰撞
        self.rect.x = random.randint(0, screen_Rect.width - self.rect.width)#随机x位置
        self.enemyLife = 2#血量
        self.timeDelay = 0#死亡图像延迟

    def update(self):
        if self.enemyLife <= 0:#判断死亡
            self.image = pygame.image.load("game_Material\\enemyDestroyed.jpg").convert_alpha()#加载死亡图像
            self.speedCol = 1#死亡时使速度与背景相同 视觉上静止
            self.timeDelay += 1
            if self.timeDelay == 10:#延迟10帧画面
                self.kill()
        if self.rect.y > screen_Rect.height:#消除屏幕外的对象 防止内存溢出
            self.kill()
        super().update()

boss.py

from basic_Sprite import*
from boss_Bullet import*
from boss_Fire import*

#boss类
class boss(basicSprite):
    def __init__(self) -> None:
        super().__init__("game_Material\\boss.jpg")
        self.rect.y = -150#优化显示
        self.rect.height -= 100#优化显示
        self.enemyLife = 12000#boss生命值
        self.timeDelay = 0#延迟爆炸图像的消失
        self.bossBullets = pygame.sprite.Group()#boss的子弹组 便于后续碰撞判断
        self.bossFires = pygame.sprite.Group()#boss的屏障组 便于后续碰撞判断
        self.bossExist = False#boss存在的标志
        self.isShot = False#boss开火的标志 由事件boss_Shot产生
        self.isFire = False#boss发出屏障的标志 由世界boss_Fire产生
    def update(self):
        if self.enemyLife <= 0:#判断是否死亡
            self.image = pygame.image.load("game_Material\\bossDestroyed.jpg").convert_alpha()#加载死亡图像
            self.timeDelay += 1#进行图像延迟
            if self.timeDelay == 100:#延迟为100帧画面
                self.bossExist = False#boss不存在
                self.enemyLife = 12000#初始化boss的生命值
                self.image = pygame.image.load("game_Material\\boss.jpg").convert_alpha()#初始化boss的图像
        super().update()
        if self.bossExist and self.isShot:#如果boss存在且标志isShot为True
            self.attack()#进行攻击
            self.isShot = False#初始化isShot
        if self.bossExist and self.isFire:#如果boss存在且标志isFire为True
            self.Fire()#发出屏障
            self.isFire = False#初始化isFire
    
    def attack(self):#boss攻击函数
        #每次攻击发射四颗子弹
        Bullet1 = bossBullet()
        Bullet1.rect.y = self.rect.y + self.rect.height
        Bullet2 = bossBullet()
        Bullet2.rect.y = self.rect.y + self.rect.height
        Bullet3 = bossBullet()
        Bullet3.rect.y = self.rect.y + self.rect.height
        Bullet4 = bossBullet()
        Bullet4.rect.y = self.rect.y + self.rect.height
        self.bossBullets.add(Bullet1)
        self.bossBullets.add(Bullet2)
        self.bossBullets.add(Bullet3)
        self.bossBullets.add(Bullet4)        

    def Fire(self):#boss发射屏障函数
        Fire = bossFire()
        self.bossFires.add(Fire)   

boss_Bullet.py/boss_Fire.py

#boss_Bullet.py

from basic_Sprite import*
import random

#boss发射的子弹
class bossBullet(basicSprite):
    def __init__(self, filename="game_Material\\bossBullet.jpg", speedRow=0, speedCol=5):
        super().__init__(filename, speedRow, speedCol)
        self.rect.x = random.randint(0, screen_Rect.width - self.rect.width)#随机出子弹的位置
    def update(self):
        super().update()
        if self.rect.y > screen_Rect.height:#消除屏幕外的子弹 防止溢出导致的崩溃
            self.kill()

#boss_Fire.py
from random import random
from basic_Sprite import*
import random

#boss屏障技能
class bossFire(basicSprite):
    def __init__(self, filename="game_Material\\bossFire.jpg", speedRow=0, speedCol=2):
        super().__init__(filename, speedRow, speedCol)
        self.rect.x = random.choice([0, 300, 100, 200, 0, 300, 50, 250, 150, 0, 300])#屏障的初始位置随机化且增加在边缘区域的概率
        self.rect.y = screen_Rect.y + 20#视觉显示优化 从boss血条下出现屏障 防止遮挡血条
    def update(self):
        super().update()
        if self.rect.y > screen_Rect.height:#消除屏幕外的对象 防止内存溢出
            self.kill()

item_Group.py

from enemy import*
from player_Plane import*
from background import*
from boss import*
import pygame

class itemGroup():
    def __init__(self) -> None:
        #背景组件
        backgroud1 = background(False)
        backgroud2 = background(True)
        self.backgroudGroup = pygame.sprite.Group()
        self.backgroudGroup.add(backgroud1)
        self.backgroudGroup.add(backgroud2)
        #敌机组件
        self.enemy = enemy()
        self.enemyGroup = pygame.sprite.Group()
        self.enemyGroup.add(self.enemy)
        self.hittenEnemyGroup = pygame.sprite.Group()
        #玩家组件
        self.playerPlane = playerPlane()
        self.playerPlaneGroup = pygame.sprite.Group()
        self.backgroudGroup.add(self.playerPlane)
        self.hittenPlayerPlane = pygame.sprite.Group()
        #boss组件
        self.Boss = boss()
        self.BossGroup = pygame.sprite.Group()
        self.BossGroup.add(self.Boss)

game.py

from item_Group import*
from enemyCollitionDetection import*
from playerCollitionDetection import*

#游戏类
class Game(itemGroup):
    def __init__(self) -> None:
        super().__init__()
        self.skillPoint = 0#技能点
        self.gamePoint = 0#分数
        self.Begin = False#是否开始游戏
    def collitionDetection(self):
        enemyCollitionDetection(self)#敌机和boss的碰撞判断逻辑
        playerCollitionDetection(self)#玩家的碰撞判断逻辑

与game.py配套的函数

#enemyCollitionDetection.py
import pygame

#奖励的区间判断 因为玩家的E技能每次-10点boss生命值 所以不一定boss声明的每个值都会出现 因此设定为一个区间
num = {2995,2996,2997,2998,2999,3000,3001,3002,3003,3004,5995,5996,5997,5998,5999,6000,6001,6002,6003,6004,8995,8996,8997,8998,8999,9000,9001,9002,9003,9004}

#敌机和boss的碰撞检测
def enemyCollitionDetection(self):
    #敌机碰撞检测
    hittenPlanes = pygame.sprite.groupcollide(self.enemyGroup,self.playerPlane.bullets,False,True)#子弹与敌机碰撞
    self.hittenEnemyGroup.add(hittenPlanes)#将被攻击的敌机加受到入攻击组
    if hittenPlanes != {}:#如果不为空
        for hittenPlane in self.hittenEnemyGroup:#取被攻击的敌机
            if hittenPlane.enemyLife != 0:#扣除生命值
                hittenPlane.enemyLife -= 1
                #统计获得的分数和技能点
                self.gamePoint += 1
                if self.skillPoint != 300 and self.playerPlane.bulletStore < 3:#防止Q技能获得技能点 设置技能点上限
                    self.skillPoint += 1    
    hittenPlanes2 = pygame.sprite.groupcollide(self.enemyGroup,self.playerPlane.fires,False,False)#玩家屏障(W)与敌机碰撞
    self.hittenEnemyGroup.add(hittenPlanes2)
    if hittenPlanes2 != {}:  
        for hittenPlane in self.hittenEnemyGroup:
            if hittenPlane.enemyLife != 0:
                hittenPlane.enemyLife -= 1
    for boom in self.playerPlane.booms:#玩家炸弹(Q)消灭敌机
        if boom != {}:#如果玩家有炸弹
            self.gamePoint += 1#加分
            for hittenPlane in self.enemyGroup:#全屏攻击
                if hittenPlane.enemyLife != 0:
                    hittenPlane.enemyLife -= 10#炸弹的伤害值

    #boss碰撞检测
    if self.Boss.bossExist:#如果有boss
        hittenPlanes3 = pygame.sprite.spritecollide(self.Boss,self.playerPlane.bullets,True)
        if len(hittenPlanes3) > 0:
            self.Boss.enemyLife -= len(hittenPlanes3)
            if self.skillPoint != 300 and self.playerPlane.bulletStore < 3:
                self.skillPoint += 1
            self.gamePoint += len(hittenPlanes3)    
        hittenPlanes4 = pygame.sprite.groupcollide(self.BossGroup,self.playerPlane.fires,False,True)#boss与玩家W碰撞 玩家W碰撞消失 并对boss造成2000伤害
        if hittenPlanes4 != {}:  
            for hittenPlane in self.BossGroup:
                if hittenPlane.enemyLife != 0:
                    hittenPlane.enemyLife -= 2000
        for boom in self.playerPlane.booms:#玩家E技能对boss造成伤害且加分
            if boom != {}:
                self.gamePoint += 1
                for hittenPlane in self.BossGroup:
                    if hittenPlane.enemyLife != 0:
                        hittenPlane.enemyLife -= 10

        if self.Boss.enemyLife in num or self.Boss.enemyLife <= 0:#boss掉1/4血量的奖励
            if self.playerPlane.playLife < 20:
                self.playerPlane.playLife += 10#血量+10
                self.playerPlane.is_Attack  = self.playerPlane.playLife
            else:
                self.playerPlane.playLife = 30
                self.playerPlane.is_Attack  = self.playerPlane.playLife                
            if self.skillPoint < 250:
                self.skillPoint += 50#能量+50
            else:
                self.skillPoint = 300

    pygame.sprite.groupcollide(self.playerPlane.bullets,self.Boss.bossBullets,True,True)#boss子弹与玩家子弹抵消  
    pygame.sprite.groupcollide(self.playerPlane.bullets,self.Boss.bossFires,True, False)#玩家子弹被boss屏障阻挡
    # if self.playerPlane.booms is not empty:
    #     self.gamePoint += 1  
    #     for hittenPlane in self.enemyGroup:
    #         if hittenPlane.enemyLife != 0:
    #             hittenPlane.enemyLife -= 10



#playerCollitionDetection.py
import pygame

#玩家碰撞检测
def playerCollitionDetection(self):
    #玩家与敌机碰撞
    enemies = pygame.sprite.spritecollide(self.playerPlane, self.enemyGroup, True)
    if len(enemies) > 0:
        self.playerPlane.playLife -= len(enemies)
        if self.playerPlane.playLife <= 0:
            self.Begin = False #gameover
    #玩家与boss子弹碰撞
    enemies2 = pygame.sprite.spritecollide(self.playerPlane, self.Boss.bossBullets, True)
    if len(enemies2) > 0:
        self.playerPlane.playLife -= len(enemies2)
        if self.playerPlane.playLife <= 0:
            self.Begin = False #gameover       
    #玩家与boss屏障碰撞
    enemies3 = pygame.sprite.spritecollide(self.playerPlane, self.Boss.bossFires, True)
    if len(enemies3) > 0:
        self.playerPlane.playLife -= 10
        if self.playerPlane.playLife <= 0:
            self.Begin = False #gameover

main.py

from game import*
from gameMonitor import*
from update import*
from keyPressed import*
import sys
import pygame

pygame.init()

#游戏初始化
screen = pygame.display.set_mode(screen_Rect.size)
pygame.display.set_caption("飞机大战")#游戏标题
icon = pygame.image.load("game_Material\\playerPlane.jpg")#游戏图标
pygame.display.set_icon(icon)#游戏图标
mainMenuBackground = pygame.image.load("game_Material\\background.jpg")#主菜单背景图
mainMenuPlane = pygame.image.load("game_Material\\playerPlane.jpg")#主菜单界面飞机
clock = pygame.time.Clock()#系统时钟

#说明文本
f = pygame.font.SysFont("Comic Sans MS", 20)
text1 = f.render("Press Enter to Begin or Esc to exit",True,(255,255,255),(0,0,0))
text2 = f.render("up/down/left/right to control your plane",True,(255,255,255),(0,0,0))
text3 = f.render("Press Space to Shot bullets",True,(255,255,255),(0,0,0))
text4 = f.render("Skills:  Q: Obtain 500 bullets W: Send a ",True,(255,255,255),(0,0,0))
text5 = f.render("Attacking enemies to gain energy and",True,(255,255,255),(0,0,0))
text6 = f.render("wall E: Throw out a bomb(have points)",True,(255,255,255),(0,0,0))
text7 = f.render("points and Q/W skills cannot be scored",True,(255,255,255),(0,0,0))
text8 = f.render("when released",True,(255,255,255),(0,0,0))
text9 = f.render("FastEnemy:30s BossEnemy:2min",True,(255,255,255),(0,0,0))
text10 = f.render("Q:1 Energy W:2 Energy E:3 Energy",True,(255,255,255),(0,0,0))
text11 =  f.render("Initially, you have 20(MAX 30) Llfes, if",True,(255,255,255),(0,0,0))
text12 = f.render("the boss lose each quarter Lifes  you will ",True,(255,255,255),(0,0,0))
text13 = f.render("get areward for 10 Lifes and 0.5 energy",True,(255,255,255),(0,0,0))

while True:#进入循环
    #初始化游戏 设置事件时钟
    pygame.time.set_timer(enemy_Create, 300)
    pygame.time.set_timer(player_Shot, 150) 
    pygame.time.set_timer(fast_Enemy, 30000)
    pygame.time.set_timer(boss_Shot, 500)
    pygame.time.set_timer(boss_Create, 120000)   
    pygame.time.set_timer(boss_Fire, 2500)
    #创建游戏
    game = Game()
    
    #开始界面
    while game.Begin != True:
        #操作设置
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    game.Begin = True
                elif event.key == pygame.K_ESCAPE:
                    pygame.quit()
                    sys.exit()
        #画面设置
        screen.blit(mainMenuBackground, (0,0))
        screen.blit(mainMenuPlane, (game.playerPlane.rect.x, game.playerPlane.rect.y))
        screen.blit(text1, (20, 50))
        screen.blit(text2, (20, 150))
        screen.blit(text3, (10, 180))
        screen.blit(text4, (20, 350))
        screen.blit(text5, (20, 450))
        screen.blit(text6, (10, 380))
        screen.blit(text7, (10, 480))
        screen.blit(text8, (10, 510))
        screen.blit(text9, (20, 550))
        screen.blit(text10,(10, 410))
        screen.blit(text11,(20, 250))
        screen.blit(text12,(10, 280))
        screen.blit(text13,(10, 310))
        pygame.display.update()    

    #开始游戏
    while game.Begin:
        pygame.key.set_repeat(0, 150)
        clock.tick(game_Frame_Rate)
        gameMonitor(game)
        keyPressed(game)
        update(game, screen)

    #结算界面
    while game.Begin != True:
        #操作界面
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    game.Begin = True
                if event.key == pygame.K_ESCAPE:
                    pygame.quit()
                    sys.exit()
        #画面设置
        screen.blit(mainMenuBackground, (0,0))
        screen.blit(text1, (20, 350))
        point = f.render("Points: {} score".format(game.gamePoint),True,(255,255,255),(0,0,0))
        screen.blit(point, (20, 400))
        pygame.display.update()   

与main.py配套的函数

#gameMonitor.py
from enemy import*
from boss import*
import sys
import pygame

#游戏事件监测
def gameMonitor(game):
    for event in pygame.event.get():
        if event.type == pygame.QUIT:#退出
            pygame.quit()
            sys.exit()
        if event.type == enemy_Create:#创建敌机事件
            enemyPlane = enemy()
            game.enemyGroup.add(enemyPlane)
        if event.type == player_Shot and game.playerPlane.bulletStore < 2:#玩家获得子弹
            game.playerPlane.bulletStore += 1
        if event.type == fast_Enemy:#创建快速编队
            for index in range(10):#10支敌机
                Enemy = enemy()
                Enemy.speedCol = 10
                game.enemyGroup.add(Enemy)
        if event.type == boss_Create:#创建boss事件
            game.Boss.bossExist = True
        if event.type == boss_Shot and game.Boss.bossExist == True:#boss发射子弹
            game.Boss.isShot = True
        if event.type == boss_Fire and game.Boss.bossExist == True:#boss发射屏障
            game.Boss.isFire = True

#keyPressed.py
import pygame

#按键逻辑 使用if使玩家可以一次按所有的键不冲突
def keyPressed(game):
    keyValue = pygame.key.get_pressed()
    if keyValue[pygame.K_SPACE] and game.playerPlane.bulletStore != 0:
        game.playerPlane.attack()
        game.playerPlane.bulletStore -= 1
    if keyValue[pygame.K_q] and game.skillPoint >= 100 and game.playerPlane.bulletStore < 400:
        game.skillPoint -= 100
        game.playerPlane.bulletStore += 500
    if keyValue[pygame.K_w] and game.skillPoint >= 200:
        game.skillPoint -= 200
        game.playerPlane.Fires()
    if keyValue[pygame.K_e] and game.skillPoint >= 250:
        game.skillPoint -= 250
        game.playerPlane.Boom()
    if keyValue[pygame.K_UP] or keyValue[pygame.K_DOWN]  or keyValue[pygame.K_LEFT] or keyValue[pygame.K_RIGHT]:    
        if keyValue[pygame.K_UP]:
            game.playerPlane.speedCol = -3
        if keyValue[pygame.K_DOWN]:
            game.playerPlane.speedCol = 3
        if keyValue[pygame.K_LEFT]:
            game.playerPlane.speedRow = -3
        if keyValue[pygame.K_RIGHT]:
            game.playerPlane.speedRow = 3
    else:
        #未操作移动则不动
        game.playerPlane.speedCol = 0
        game.playerPlane.speedRow = 0

    #开始的写法 按键有些许冲突且不顺滑
        # if event.type == pygame.KEYDOWN:
        #     if event.key == pygame.K_SPACE:
        #         game.playerPlane.attack()
        #     elif event.key == pygame.K_UP: 
        #         game.playerPlane.speedCol = -3
        #     elif event.key == pygame.K_DOWN:
        #         game.playerPlane.speedCol = 3
        #     elif event.key == pygame.K_LEFT:
        #         game.playerPlane.speedRow = -3
        #     elif event.key == pygame.K_RIGHT:
        #         game.playerPlane.speedRow = 3
        # elif event.type == pygame.KEYUP:
        #         game.playerPlane.speedCol = 0
        #         game.playerPlane.speedRow = 0 


#update.py
import pygame
from basic_Sprite import*

def update(game, screen):
    game.collitionDetection()#碰撞检测
    #各元素组件更新
    game.backgroudGroup.update()
    game.backgroudGroup.draw(screen)
    game.enemyGroup.update()
    game.enemyGroup.draw(screen)
    game.playerPlane.bullets.update()
    game.playerPlane.bullets.draw(screen)
    game.playerPlane.fires.update()
    game.playerPlane.fires.draw(screen)
    game.playerPlane.booms.update()
    game.playerPlane.booms.draw(screen)
    game.playerPlaneGroup.update()
    game.playerPlaneGroup.draw(screen)
    if game.Boss.bossExist:#boss存在才更新
        game.BossGroup.update()
        game.BossGroup.draw(screen)
        game.Boss.bossBullets.update()
        game.Boss.bossBullets.draw(screen)
        game.Boss.bossFires.update()
        game.Boss.bossFires.draw(screen)
        screen.fill((255,0,0),rect=(0,0,game.Boss.enemyLife/30,10))
    #UI的绘制
    screen.fill((255,0,0),rect=(0,screen_Rect.height-game.playerPlane.playLife*10,10,game.playerPlane.playLife*10))#玩家血条
    screen.fill((0,0,255),rect=(12,screen_Rect.height-game.skillPoint/2,10,game.skillPoint/2))#玩家蓝条
    screen.fill((0,0,0),rect=(12,screen_Rect.height-50,10,2))#蓝条低分段条
    screen.fill((0,0,0),rect=(12,screen_Rect.height-100,10,2))#蓝条高分段条
    #分数的绘制
    f = pygame.font.SysFont("Comic Sans MS", 20)
    point = f.render("{}'".format(game.gamePoint),True,(255,255,255),(0,0,0))
    screen.blit(point, (360, 650))  
    #屏幕更新
    pygame.display.update()

海纳百川 有容乃大