From f8be222cafe0679f6bc4d4b391ab1f218d471c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Sun, 15 May 2022 15:46:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=8F=98=E9=87=8F=E5=90=8D?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=94=B9=E5=A4=A7=E5=98=B4=E8=8A=B1=E6=94=BB?= =?UTF-8?q?=E5=87=BB=E5=AE=9E=E7=8E=B0=E6=9C=AC=E8=B4=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/component/plant.py | 9 ++++----- source/state/level.py | 15 +-------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/source/component/plant.py b/source/component/plant.py index 4aa947a..821fc19 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -636,7 +636,7 @@ class Chomper(Plant): if self.frame_index == (self.frame_num - 3): # 播放吞的音效 pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "bigchomp.ogg")).play() - self.zombie_group.remove(self.attack_zombie) + self.attack_zombie.kill() if (self.frame_index + 1) == self.frame_num: self.setDigest() @@ -645,7 +645,6 @@ class Chomper(Plant): self.digest_timer = self.current_time elif (self.current_time - self.digest_timer) > self.digest_interval: self.digest_timer = 0 - self.attack_zombie.kill() self.setIdle() @@ -753,7 +752,7 @@ class Squash(Plant): Plant.__init__(self, x, y, c.SQUASH, c.PLANT_HEALTH, None) self.orig_pos = (x, y) self.aim_timer = 0 - self.squashing = False + self.start_boom = False # 和灰烬等植物统一变量名,在这里表示倭瓜是否跳起 self.mapPlantsSet = mapPlantsSet def loadImages(self, name, scale): @@ -792,7 +791,7 @@ class Squash(Plant): self.health = c.INF def attacking(self): - if self.squashing: + if self.start_boom: if (self.frame_index + 1) == self.frame_num: for zombie in self.zombie_group: if self.canAttack(zombie): @@ -810,7 +809,7 @@ class Squash(Plant): elif (self.current_time - self.aim_timer) > 1000: self.changeFrames(self.attack_frames) self.rect.centerx = self.attack_zombie.rect.centerx - self.squashing = True + self.start_boom = True self.animate_interval = 300 def getPosition(self): diff --git a/source/state/level.py b/source/state/level.py index 7a73e6d..6d4682a 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -1009,10 +1009,6 @@ class Level(tool.State): for bullet in self.bullet_groups[i]: if bullet.name == c.FUME: continue - # elif bullet.name == c.BULLET_STAR: - # collided_func = pg.sprite.collide_circle_ratio(1) - # else: - # collided_func = pg.sprite.collide_circle_ratio(0.7) collided_func = pg.sprite.collide_mask if bullet.state == c.FLY: # 利用循环而非内建精灵组碰撞判断函数,处理更加灵活,可排除已死亡僵尸 @@ -1030,11 +1026,6 @@ class Level(tool.State): def checkZombieCollisions(self): - # if self.bar_type == c.CHOSSEBAR_BOWLING: - # ratio = 0.6 - # else: - # ratio = 0.5 - # collided_func = pg.sprite.collide_circle_ratio(ratio) for i in range(self.map_y_len): hypo_zombies = [] for zombie in self.zombie_groups[i]: @@ -1087,11 +1078,7 @@ class Level(tool.State): attackableCommonPlants.append(plant) # 在某些状态下忽略啃食碰撞但某些状况下不能忽略的情形 elif plant.name in c.SKIP_ZOMBIE_COLLISION_CHECK_WHEN_WORKING: - if plant.name == c.SQUASH: - if not plant.squashing: - attackableCommonPlants.append(plant) - else: - if not plant.start_boom: + if not plant.start_boom: attackableCommonPlants.append(plant) else: if attackableCommonPlants: