1 Star 1 Fork 0

snowfoxhasdream/PlaneWar

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
supply.py 2.33 KB
一键复制 编辑 原始数据 按行查看 历史
snowfoxhasdream 提交于 2021-12-25 07:50 . add python files.
import pygame
from settings import *
from random import randint
class BulletSupply(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
self.image = pygame.image.load(FILE_PATH + "image/bullet_supply.png").convert_alpha()
self.rect = self.image.get_rect()
self.rect.left = randint(0, SCREEN_RECT.width - self.rect.width)
self.rect.bottom = -100
self.speed = 3
self.active = False
self.mask = pygame.mask.from_surface(self.image)
def move(self):
if self.rect.top < SCREEN_RECT.height:
self.rect.top += self.speed
else:
self.active = False
def reset(self):
self.active = True
self.rect.left = randint(0, SCREEN_RECT.width - self.rect.width)
self.rect.bottom = -100
class BombSupply(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
self.image = pygame.image.load(FILE_PATH + "image/bomb_supply.png").convert_alpha()
self.rect = self.image.get_rect()
self.rect.left = randint(0, SCREEN_RECT.width - self.rect.width)
self.rect.bottom = -100
self.speed = 3
self.active = False
self.mask = pygame.mask.from_surface(self.image)
def move(self):
if self.rect.top < SCREEN_RECT.height:
self.rect.top += self.speed
else:
self.active = False
def reset(self):
self.active = True
self.rect.left = randint(0, SCREEN_RECT.width - self.rect.width)
self.rect.bottom = -100
class LifeSupply(pygame.sprite.Sprite):
def __init__(self):
super().__init__()
self.image = pygame.image.load(FILE_PATH + "image/life_supply.png").convert_alpha()
self.rect = self.image.get_rect()
self.rect.left = randint(0, SCREEN_RECT.width - self.rect.width)
self.rect.bottom = -100
self.speed = 3
self.active = False
self.mask = pygame.mask.from_surface(self.image)
def move(self):
if self.rect.top < SCREEN_RECT.height:
self.rect.top += self.speed
else:
self.active = False
def reset(self):
self.active = True
self.rect.left = randint(0, SCREEN_RECT.width - self.rect.width)
self.rect.bottom = -100
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/snowfoxhasdream/PlaneWar.git
[email protected]:snowfoxhasdream/PlaneWar.git
snowfoxhasdream
PlaneWar
PlaneWar
master

搜索帮助