From 0f59007e82300fb72fd073a0e3c32a37399fafb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Mon, 1 Aug 2022 22:53:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B0=8F=E6=8E=A8=E8=BD=A6?= =?UTF-8?q?=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/state/level.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/state/level.py b/source/state/level.py index f1d2d06..71b9f8e 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -312,7 +312,7 @@ class Level(tool.State): self.cars = [] for i in range(self.map_y_len): y = self.map.getMapGridPos(0, i)[1] - self.cars.append(plant.Car(-40, y+20, i)) + self.cars.append(plant.Car(-45, y+20, i)) # 更新函数每帧被调用,将鼠标事件传入给状态处理函数 def update(self, surface, current_time, mouse_pos, mouse_click): @@ -1177,9 +1177,10 @@ class Level(tool.State): for i in range(len(self.cars)): if self.cars[i]: for zombie in self.zombie_groups[i]: - if zombie and zombie.state != c.DIE and (not zombie.losthead) and (zombie.rect.centerx <= 0): + if (zombie and zombie.state != c.DIE and (not zombie.losthead) + and (pg.sprite.collide_mask(zombie, self.cars[i]))): self.cars[i].setWalk() - if zombie.rect.centerx <= self.cars[i].rect.x: + if pg.sprite.collide_mask(zombie, self.cars[i]): zombie.health = 0 if self.cars[i].dead: self.cars[i] = None