From 1733a8ea0c4b23487841453173d9a20998b2a110 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 19:19:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=80=AD=E7=93=9C=E6=94=B9=E4=B8=BA=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 --- resources/data/map/level_0.json | 8 ++++++++ source/component/plant.py | 12 +++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/resources/data/map/level_0.json b/resources/data/map/level_0.json index ec95b95..58007dd 100644 --- a/resources/data/map/level_0.json +++ b/resources/data/map/level_0.json @@ -5,6 +5,14 @@ "spawn_zombies":"list", "zombie_list":[ {"time":0, "map_y":4, "name":"ScreenDoorZombie"}, + {"time":1000, "map_y":4, "name":"ScreenDoorZombie"}, + {"time":2000, "map_y":4, "name":"ScreenDoorZombie"}, + {"time":3100, "map_y":4, "name":"ScreenDoorZombie"}, + {"time":4500, "map_y":4, "name":"ScreenDoorZombie"}, + {"time":5000, "map_y":4, "name":"ScreenDoorZombie"}, + {"time":6000, "map_y":4, "name":"ScreenDoorZombie"}, + {"time":7000, "map_y":4, "name":"ScreenDoorZombie"}, + {"time":8000, "map_y":4, "name":"ScreenDoorZombie"}, {"time":0, "map_y":1, "name":"NewspaperZombie"}, {"time":0, "map_y":2, "name":"ConeheadDuckyTubeZombie"}, {"time":80000, "map_y":2, "name":"ConeheadDuckyTubeZombie"} diff --git a/source/component/plant.py b/source/component/plant.py index 0db0a42..1038edb 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -668,15 +668,9 @@ class Squash(Plant): return True # 攻击状态 elif (self.state == c.ATTACK): - # 僵尸在倭瓜右侧 - if zombie.rect.x >= self.rect.x: - # 重叠20个像素或15%判断为可以攻击 - if (self.rect.right - zombie.rect.left >= 20) or (self.rect.right - zombie.rect.left >= 0.15*zombie.rect.width): - return True - # 僵尸在倭瓜右侧 - else: - if (zombie.rect.right - self.rect.left >= 20) or (zombie.rect.right - self.rect.left >= 0.15*zombie.rect.width): - return True + # 碰撞检测 + if pg.sprite.collide_circle_ratio(0.7)(zombie, self): + return True return False def setAttack(self, zombie, zombie_group):