• 大小: 1.57MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-19
  • 语言: Python
  • 标签: python  游戏  代码  

资源简介

Python项目实战Python项目实战Python项目实战Python项目实战Python项目实战Python项目实战Python项目实战Python项目实战Python项目实战Python项目实战Python项目实战

资源截图

代码片段和文件信息

import pygame
from random import *

class SmallEnemy(pygame.sprite.Sprite):
    def __init__(self bg_size):
        pygame.sprite.Sprite.__init__(self)

        self.image = pygame.image.load(“images/enemy1.png“).convert_alpha()
        self.destroy_images = []
        self.destroy_images.extend([\
            pygame.image.load(“images/enemy1_down1.png“).convert_alpha() \
            pygame.image.load(“images/enemy1_down2.png“).convert_alpha() \
            pygame.image.load(“images/enemy1_down3.png“).convert_alpha() \
            pygame.image.load(“images/enemy1_down4.png“).convert_alpha() \
            ])
        self.rect = self.image.get_rect()
        self.width self.height = bg_size[0] bg_size[1]
        self.speed = 2
        self.active = True
        self.rect.left self.rect.top = \
                        randint(0 self.width - self.rect.width) \
                        randint(-5 * self.height 0)
        self.mask = pygame.mask.from_surface(self.image)

    def move(self):
        if self.rect.top < self.height:
            self.rect.top += self.speed
        else:
            self.reset()

    def reset(self):
        self.active = True
        self.rect.left self.rect.top = \
                        randint(0 self.width - self.rect.width) \
                        randint(-5 * self.height 0)


class MidEnemy(pygame.sprite.Sprite):
    energy = 8
    
    def __init__(self bg_size):
        pygame.sprite.Sprite.__init__(self)

        self.image = pygame.image.load(“images/enemy2.png“).convert_alpha()
        self.image_hit = pygame.image.load(“images/enemy2_hit.png“).convert_alpha()
        self.destroy_images = []
        self.destroy_images.extend([\
            pygame.image.load(“images/enemy2_down1.png“).convert_alpha() \
            pygame.image.load(“images/enemy2_down2.png“).convert_alpha() \
            pygame.image.load(“images/enemy2_down3.png“).convert_alpha() \
            pygame.image.load(“images/enemy2_down4.png“).convert_alpha() \
            ])
        self.rect = self.image.get_rect()
        self.width self.height = bg_size[0] bg_size[1]
        self.speed = 1
        self.active = True
        self.rect.left self.rect.top = \
                        randint(0 self.width - self.rect.width) \
                        randint(-10 * self.height -self.height)
        self.mask = pygame.mask.from_surface(self.image)
        self.energy = MidEnemy.energy
        self.hit = False

    def move(self):
        if self.rect.top < self.height:
            self.rect.top += self.speed
        else:
            self.reset()

    def reset(self):
        self.active = True
        self.energy = MidEnemy.energy
        self.rect.left self.rect.top = \
                        randint(0 self.width - self.rect.width) \
                        randint(-10 * self.height -self.height)


class BigEnemy(pygame.sprite.Sprite):
    energ

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        228  2018-04-20 21:19  Plane\.idea\inspectionProfiles\profiles_settings.xml

     文件        212  2018-04-20 21:19  Plane\.idea\misc.xml

     文件        262  2018-04-20 21:19  Plane\.idea\modules.xml

     文件        284  2018-04-20 21:19  Plane\.idea\Plane.iml

     文件       1361  2018-04-20 21:19  Plane\.idea\workspace.xml

     文件       4771  2018-04-20 21:19  Plane\enemy.py

     文件      78500  2018-04-20 21:19  Plane\font\font.ttf

     文件       6567  2018-04-20 21:19  Plane\images\again.png

     文件      32756  2018-04-20 21:19  Plane\images\background.png

     文件       8480  2018-04-20 21:19  Plane\images\bomb.png

     文件       9964  2018-04-20 21:19  Plane\images\bomb_supply.png

     文件       2989  2018-04-20 21:19  Plane\images\bullet1.png

     文件       2989  2018-04-20 21:19  Plane\images\bullet2.png

     文件       9706  2018-04-20 21:19  Plane\images\bullet_supply.png

     文件       5499  2018-04-20 21:19  Plane\images\enemy1.png

     文件       5797  2018-04-20 21:19  Plane\images\enemy1_down1.png

     文件       6181  2018-04-20 21:19  Plane\images\enemy1_down2.png

     文件       7361  2018-04-20 21:19  Plane\images\enemy1_down3.png

     文件       4199  2018-04-20 21:19  Plane\images\enemy1_down4.png

     文件      10918  2018-04-20 21:19  Plane\images\enemy2.png

     文件      12527  2018-04-20 21:19  Plane\images\enemy2_down1.png

     文件      13315  2018-04-20 21:19  Plane\images\enemy2_down2.png

     文件      14680  2018-04-20 21:19  Plane\images\enemy2_down3.png

     文件       5500  2018-04-20 21:19  Plane\images\enemy2_down4.png

     文件      11712  2018-04-20 21:19  Plane\images\enemy2_hit.png

     文件      47670  2018-04-20 21:19  Plane\images\enemy3_down1.png

     文件      50549  2018-04-20 21:19  Plane\images\enemy3_down2.png

     文件      56999  2018-04-20 21:19  Plane\images\enemy3_down3.png

     文件      60637  2018-04-20 21:19  Plane\images\enemy3_down4.png

     文件      67264  2018-04-20 21:19  Plane\images\enemy3_down5.png

............此处省略48个文件信息

评论

共有 条评论