• 大小: 83.02MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2023-04-15
  • 语言: 其他
  • 标签: python  pygame  

资源简介

实习过程自己开发的小游戏——飞机大战,这次是代码文件,刚刚脑子秀逗了,上传错了 实现功能:单双人模式选择;游戏暂停(重新开始,继续游戏,结束游戏);导弹功能;敌机发射子弹;各种升级包(生命、子弹、满级子弹、免疫);场景切换;大boss等 会有bug,但基本功能都可以,内存回收问题也有解决

资源截图

代码片段和文件信息

from random import *
import pygame

class Background(pygame.sprite.Sprite):
    def __init__(selfpositionbg_size):
        pygame.sprite.Sprite.__init__(self)

        self.widthself.height = bg_size[0]bg_size[1]

        self.image = pygame.image.load(‘image/aircraft_image/image_2.jpg‘).convert_alpha()

        self.images = []
        self.images.extend([ \
            pygame.image.load(‘image/aircraft_image/image_3.jpg‘).convert_alpha() \
            pygame.image.load(‘image/aircraft_image/image_4.jpg‘).convert_alpha() \
            pygame.image.load(‘image/aircraft_image/image_5.jpg‘).convert_alpha()

        ])

        self.rect = self.image.get_rect()
        self.rect.leftself.rect.bottom = position
        self.speed = 1
        self.alive = False

    def move(self):
        self.rect.top+=self.speed
            
        if self.rect.bottom>self.height:
                self.alive = True

            

class Cloud(pygame.sprite.Sprite):
    def __init__(selfbg_size):
        pygame.sprite.Sprite.__init__(self)

        
        self.image = pygame.image.load(‘image/aircraft_image/img_cloud_1.png‘).convert_alpha()
        self.images = pygame.image.load(‘image/aircraft_image/img_cloud_2.png‘).convert_alpha()
        self.image_s = choice([self.imageself.images])
        self.image_rect = self.image_s.get_rect()
        self.widthself.height = bg_size[0]bg_size[1]
        self.image_rect.leftself.image_rect.bottom = choice([(self.width-self.image_rect.width//2)(0-self.image_rect.width//2)])\
                                                      randint(-100-10)
        self.speed = 1


        
    def move(self):                
            if self.image_rect.top < self.height:
                    self.image_rect.top+=1
            else:
                self.reset()
    def reset(self):
            
            self.image_s = choice([self.imageself.images])
            self.image_rect = self.image_s.get_rect()
            self.image_rect.leftself.image_rect.bottom = randint(0-self.image_rect.width//2self.width-self.image_rect.width//2)\
                                                       randint(-50-10)
    

            

                                                           
                                        






        
        
            
        
        
    


                






        


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-07-20 10:07  our_aircraft_Final\
     目录           0  2018-07-20 10:10  our_aircraft_Final\.idea\
     文件          17  2018-07-20 10:09  our_aircraft_Final\.idea\.name
     目录           0  2018-07-19 15:04  our_aircraft_Final\.idea\inspectionProfiles\
     文件         404  2018-07-19 00:51  our_aircraft_Final\.idea\inspectionProfiles\Project_Default.xml
     文件         185  2018-07-19 15:05  our_aircraft_Final\.idea\misc.xml
     文件         328  2018-07-20 10:10  our_aircraft_Final\.idea\modules.xml
     文件         487  2018-07-20 10:10  our_aircraft_Final\.idea\our_aircraft_Boss.iml
     文件       28449  2018-07-20 10:10  our_aircraft_Final\.idea\workspace.xml
     目录           0  2018-07-20 10:07  our_aircraft_Final\__pycache__\
     文件        2185  2018-07-19 10:18  our_aircraft_Final\__pycache__\background.cpython-36.pyc
     文件        5897  2018-07-19 19:41  our_aircraft_Final\__pycache__\bullet.cpython-36.pyc
     文件        7003  2018-07-18 23:32  our_aircraft_Final\__pycache__\button.cpython-36.pyc
     文件        6805  2018-07-19 11:27  our_aircraft_Final\__pycache__\define.cpython-36.pyc
     文件       13816  2018-07-20 10:07  our_aircraft_Final\__pycache__\double_game.cpython-36.pyc
     文件       10619  2018-07-19 16:50  our_aircraft_Final\__pycache__\enemy.cpython-36.pyc
     文件        6217  2018-07-19 12:47  our_aircraft_Final\__pycache__\gameover.cpython-36.pyc
     文件        1699  2018-07-19 09:30  our_aircraft_Final\__pycache__\globalPage.cpython-36.pyc
     文件        4233  2018-07-19 10:16  our_aircraft_Final\__pycache__\missile.cpython-36.pyc
     文件       14816  2018-07-19 20:05  our_aircraft_Final\__pycache__\myplane.cpython-36.pyc
     文件        2409  2018-07-19 14:46  our_aircraft_Final\__pycache__\prop.cpython-36.pyc
     文件       12030  2018-07-20 10:04  our_aircraft_Final\__pycache__\single_game.cpython-36.pyc
     文件         844  2018-07-18 23:32  our_aircraft_Final\__pycache__\startPage_bg.cpython-36.pyc
     文件        2092  2018-07-18 23:32  our_aircraft_Final\__pycache__\supply.cpython-36.pyc
     目录           0  2018-07-19 15:04  our_aircraft_Final\audio\
     文件       77012  2016-12-19 19:44  our_aircraft_Final\audio\bg_logobg.mp3
     文件      134063  2016-12-19 19:44  our_aircraft_Final\audio\bgm_cunshiqujinbi.mp3
     文件      370419  2016-12-19 19:44  our_aircraft_Final\audio\bgm_dfzhandou.mp3
     文件      388287  2016-12-19 19:44  our_aircraft_Final\audio\bgm_jizhanboss1.mp3
     文件      359448  2016-12-19 19:44  our_aircraft_Final\audio\bgm_jizhanboss2.mp3
     文件      380763  2016-12-19 19:44  our_aircraft_Final\audio\bgm_jizhanboss3.mp3
............此处省略1504个文件信息

评论

共有 条评论