From 189334d5616fd42cd5994ae7d41baa7b38b95827 Mon Sep 17 00:00:00 2001 From: marblexu <314299052@qq.com> Date: Wed, 18 Sep 2019 21:44:24 +0800 Subject: [PATCH] modify chomper attack range --- source/component/plant.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/component/plant.py b/source/component/plant.py index 195f8e0..212bf01 100644 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -380,7 +380,8 @@ class Chomper(Plant): def canAttack(self, zombie): if (self.state == c.IDLE and zombie.state != c.DIGEST and - (self.rect.right + c.GRID_X_SIZE//3 * 2 >= zombie.rect.x)): + self.rect.x <= zombie.rect.right and + (self.rect.right + c.GRID_X_SIZE//3 >= zombie.rect.x)): return True return False @@ -419,8 +420,8 @@ class Chomper(Plant): self.frame_index = 0 bottom = self.rect.bottom - centerx = self.rect.centerx + x = self.rect.x self.image = self.frames[self.frame_index] self.rect = self.image.get_rect() self.rect.bottom = bottom - self.rect.centerx = centerx + self.rect.x = x