From 6dfd5a4a17bfe85df812db8b6f1c687b71802148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Fri, 8 Apr 2022 15:40:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=8F=8C=E5=8F=91=E5=B0=84?= =?UTF-8?q?=E6=89=8B=E7=9A=84=E5=AE=9E=E7=8E=B0=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=AD=90=E5=BC=B9=E8=B5=B7=E5=A7=8B=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/component/plant.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/source/component/plant.py b/source/component/plant.py index b815779..523d741 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -282,7 +282,7 @@ class PeaShooter(Plant): def attacking(self): if (self.current_time - self.shoot_timer) > 1400: - self.bullet_group.add(Bullet(self.rect.right, self.rect.y, self.rect.y, + self.bullet_group.add(Bullet(self.rect.right - 15, self.rect.y, self.rect.y, c.BULLET_PEA, c.BULLET_DAMAGE_NORMAL, False)) self.shoot_timer = self.current_time @@ -292,13 +292,19 @@ class RepeaterPea(Plant): Plant.__init__(self, x, y, c.REPEATERPEA, c.PLANT_HEALTH, bullet_group) self.shoot_timer = 0 + # 是否发射第一颗 + self.firstShot = False + def attacking(self): - if (self.current_time - self.shoot_timer) > 1400: - self.bullet_group.add(Bullet(self.rect.right, self.rect.y, self.rect.y, - c.BULLET_PEA, c.BULLET_DAMAGE_NORMAL, False)) - self.bullet_group.add(Bullet(self.rect.right + 40, self.rect.y, self.rect.y, + if (self.current_time - self.shoot_timer > 1400): + self.firstShot = True + self.bullet_group.add(Bullet(self.rect.right - 15, self.rect.y, self.rect.y, c.BULLET_PEA, c.BULLET_DAMAGE_NORMAL, False)) self.shoot_timer = self.current_time + elif self.firstShot and (self.current_time - self.shoot_timer) > 200: + self.firstShot = False + self.bullet_group.add(Bullet(self.rect.right - 15, self.rect.y, self.rect.y, + c.BULLET_PEA, c.BULLET_DAMAGE_NORMAL, False)) class ThreePeaShooter(Plant): @@ -316,7 +322,7 @@ class ThreePeaShooter(Plant): if tmp_y < 0 or tmp_y >= c.GRID_Y_LEN: continue dest_y = self.rect.y + (i - 1) * c.GRID_Y_SIZE + offset_y - self.bullet_groups[tmp_y].add(Bullet(self.rect.right, self.rect.y, dest_y, + self.bullet_groups[tmp_y].add(Bullet(self.rect.right - 15, self.rect.y, dest_y, c.BULLET_PEA, c.BULLET_DAMAGE_NORMAL, False)) self.shoot_timer = self.current_time @@ -328,7 +334,7 @@ class SnowPeaShooter(Plant): def attacking(self): if (self.current_time - self.shoot_timer) > 1400: - self.bullet_group.add(Bullet(self.rect.right, self.rect.y, self.rect.y, + self.bullet_group.add(Bullet(self.rect.right - 15, self.rect.y, self.rect.y, c.BULLET_PEA_ICE, c.BULLET_DAMAGE_NORMAL, True)) self.shoot_timer = self.current_time @@ -736,7 +742,7 @@ class ScaredyShroom(Plant): def attacking(self): if (self.current_time - self.shoot_timer) > 1400: - self.bullet_group.add(Bullet(self.rect.right, self.rect.y + 40, self.rect.y + 40, + self.bullet_group.add(Bullet(self.rect.right - 15, self.rect.y + 40, self.rect.y + 40, c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, True)) self.shoot_timer = self.current_time