From 1f42c0271fc6e855ca7bc5c91f601661af72240b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Sat, 9 Apr 2022 12:02:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B0=8F=E6=8E=A8=E8=BD=A6?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/constants.py | 2 ++ source/state/level.py | 10 +++++----- source/tool.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/source/constants.py b/source/constants.py index 9030499..7f83ea1 100755 --- a/source/constants.py +++ b/source/constants.py @@ -13,6 +13,8 @@ GRID_Y_LEN = 5 GRID_X_SIZE = 80 GRID_Y_SIZE = 100 +# 游戏速度倍率(调试用) +GAME_RATE = 1 WHITE = (255, 255, 255) NAVYBLUE = ( 60, 60, 100) diff --git a/source/state/level.py b/source/state/level.py index be713c7..f013e6c 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -628,13 +628,13 @@ class Level(tool.State): hypno_zombie.setAttack(zombie, False) def checkCarCollisions(self): - collided_func = pg.sprite.collide_circle_ratio(0.6) 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 and (not zombie.lostHead): + for zombie in self.zombie_groups[car.map_y]: + if zombie and zombie.state != c.DIE and (not zombie.lostHead) and zombie.rect.x <= 0: car.setWalk() - zombie.setDie() + if zombie.rect.x <= car.rect.x: + zombie.health = 0 + zombie.kill() if car.dead: self.cars.remove(car) diff --git a/source/tool.py b/source/tool.py index 2de067c..19675b9 100755 --- a/source/tool.py +++ b/source/tool.py @@ -54,7 +54,7 @@ class Control(): def update(self): # 返回自 pygame_init() 调用以来的毫秒数 - self.current_time = pg.time.get_ticks() + self.current_time = pg.time.get_ticks() * c.GAME_RATE if self.state.done: self.flip_state()