From 4f9df6de3829a0a663cc8281e47bba786ec4e6be 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, 6 May 2022 18:13:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=9F=B3=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/component/plant.py | 2 +- source/state/level.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/component/plant.py b/source/component/plant.py index d5127a0..69d7ad2 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -148,7 +148,7 @@ class StarBullet(Bullet): else: self.rect.x -= 10 self.handleMapYPosition() - if ((self.rect.x > c.SCREEN_WIDTH) or (self.rect.x < 0) + if ((self.rect.x > c.SCREEN_WIDTH) or (self.rect.x < -20) or (self.rect.y > c.SCREEN_HEIGHT) or (self.rect.y < 0)): self.kill() elif self.state == c.EXPLODE: diff --git a/source/state/level.py b/source/state/level.py index d60f3b1..406cb3b 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -1018,7 +1018,7 @@ class Level(tool.State): if ((abs(zombie.rect.centerx - x) <= plant.explode_x_range) or ((zombie.rect.right - (x-plant.explode_x_range) > 20) or (zombie.rect.right - (x-plant.explode_x_range))/zombie.rect.width > 0.2, ((x+plant.explode_x_range) - zombie.rect.left > 20) or ((x+plant.explode_x_range) - zombie.rect.left)/zombie.rect.width > 0.2)[zombie.rect.x > x]): # 这代码不太好懂,后面是一个判断僵尸在左还是在右,前面是一个元组,[0]是在左边的情况,[1]是在右边的情况 zombie.setDamage(1800, damageType=c.ZOMBIE_RANGE_DAMAGE) - else: + elif plant.name != c.WALLNUTBOWLING: # 触发植物死亡音效 pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "plantDie.ogg")).play() else: