From 7da24ee07ab0a716416ea4651b4d623b14158321 Mon Sep 17 00:00:00 2001 From: ppqz7ofga <1377053057@qq.com> Date: Tue, 30 Apr 2024 19:32:31 +0800 Subject: [PATCH] ADD file via upload --- PeaBullet.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 PeaBullet.py diff --git a/PeaBullet.py b/PeaBullet.py new file mode 100644 index 0000000..6753162 --- /dev/null +++ b/PeaBullet.py @@ -0,0 +1,22 @@ +# PeaBullet.py +import pygame +from Constant import scrrr_width + + +# 豌豆子弹类 +class PeaBullet(pygame.sprite.Sprite): + def __init__(self, peashooter, damage): + self.live = True + self.image = pygame.image.load("imgs/peabullet.png") + self.damage = damage + self.speed = 10 + self.rect = self.image.get_rect() + self.rect.x = peashooter.rect.x + 60 + self.rect.y = peashooter.rect.y + 15 + + def move_bullet(self): + # 在屏幕范围内,实现往右移动 + if self.rect.x < scrrr_width: + self.rect.x += self.speed + else: + self.live = False