From 2c140577a1c939eaf858874dea33d7beb779227f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Sat, 14 May 2022 23:23:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=80=AD=E7=93=9C=E7=A2=B0?= =?UTF-8?q?=E6=92=9E=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/component/plant.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/component/plant.py b/source/component/plant.py index f7c310a..c71e89d 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -780,6 +780,16 @@ class Squash(Plant): return True # 攻击状态 elif (self.state == c.ATTACK): + # 位置检测 + # 僵尸在倭瓜右侧 + if zombie.rect.x >= self.rect.x: + # 重叠15%判断为可以攻击 + if (self.rect.right - zombie.rect.left >= 0.15*zombie.rect.width): + return True + # 僵尸在倭瓜右侧 + else: + if (zombie.rect.right - self.rect.left >= 0.15*zombie.rect.width): + return True # 碰撞检测 if pg.sprite.collide_mask(zombie, self): return True