修复已经死亡的僵尸会触发的问题

This commit is contained in:
星外之神 2022-04-06 23:27:55 +08:00
parent 8019b4d254
commit 9ef05b2226
4 changed files with 7 additions and 8 deletions

View File

@ -80,7 +80,6 @@ nuitka --mingw --standalone --onefile --show-progress --show-memory --output-dir
## 已知bug
以下问题囿于个人目前的能力与精力,没有修复:
* 经死亡的僵尸会触发大嘴花、土豆雷甚至小推车
* 冷冻的僵尸未用蓝色滤镜标识
* 魅惑的僵尸未用红色滤镜标识
* 暂停游戏时僵尸与阳光的生成仍在计时

View File

@ -1,5 +1,5 @@
{
"background_type":0,
"background_type":1,
"init_sun_value":5000,
"shovel":1,
"zombie_list":[

View File

@ -195,7 +195,7 @@ class Plant(pg.sprite.Sprite):
self.image.set_alpha(192)
def canAttack(self, zombie):
if (self.state != c.SLEEP and zombie.state != c.DIE and
if (self.state != c.SLEEP and zombie.state != c.DIE and (not zombie.lostHead) and
self.rect.x <= zombie.rect.right):
return True
return False
@ -428,7 +428,7 @@ class Chomper(Plant):
def canAttack(self, zombie):
if (self.state == c.IDLE and zombie.state != c.DIGEST and
self.rect.x <= zombie.rect.right and
self.rect.x <= zombie.rect.right and (not zombie.lostHead) and
(self.rect.right + c.GRID_X_SIZE >= zombie.rect.x)):
return True
return False
@ -491,7 +491,7 @@ class PuffShroom(Plant):
def canAttack(self, zombie):
if (self.rect.x <= zombie.rect.right and
(self.rect.right + c.GRID_X_SIZE * 4 >= zombie.rect.x)):
(self.rect.x + c.GRID_X_SIZE * 3.5 >= zombie.rect.x)):
return True
return False
@ -532,7 +532,7 @@ class PotatoMine(Plant):
self.is_init = False
def canAttack(self, zombie):
if (not self.is_init and zombie.rect.right >= self.rect.x and
if (not self.is_init and zombie.rect.right >= self.rect.x and (not zombie.lostHead) and
(zombie.rect.x - self.rect.x) <= self.explode_x_range):
return True
return False

View File

@ -572,7 +572,7 @@ class Level(tool.State):
for car in self.cars:
zombies = pg.sprite.spritecollide(car, self.zombie_groups[car.map_y], False, collided_func)
for zombie in zombies:
if zombie and zombie.state != c.DIE:
if zombie and zombie.state != c.DIE and (not zombie.lostHead):
car.setWalk()
zombie.setDie()
if car.dead:
@ -707,7 +707,7 @@ class Level(tool.State):
def checkLose(self):
for i in range(self.map_y_len):
for zombie in self.zombie_groups[i]:
if zombie.rect.right < 0:
if zombie.rect.right < 0 and (not zombie.lostHead):
return True
return False