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()