def colision_handling(): if PLAYER.rect.colliderect(LEVEL.END) and len(LEVEL.CHECKPOINTS)==0: MESSAGE.set_text(get_end_string()) SOUNDS.play_fx(12) PLAYER.set_to_start() new_level() maze_colision() checkpoints_colision()
def checkpoints_colision(): for index,c in enumerate(LEVEL.CHECKPOINTS): if PLAYER.rect.colliderect(c): LEVEL.VISITED.append(LEVEL.CHECKPOINTS.pop(index)) MESSAGE.set_text(get_checkpoint_string(len(LEVEL.VISITED))) if len(LEVEL.CHECKPOINTS) > 0: SOUNDS.play_fx(1) else: SOUNDS.play_fx(2)
def maze_colision(): collided = False for r in LEVEL.MAZERECTS: if PLAYER.rect.colliderect(r): collided = True if PLAYER.rect.x < 0 \ or PLAYER.rect.y <0 \ or PLAYER.rect.x > width\ or PLAYER.rect.y > height: collided = True if collided: SOUNDS.play_fx(0) MESSAGE.set_text(get_death_string(len(LEVEL.VISITED))) PLAYER.set_to_start() LEVEL.reset()
def move_right(self): self.my = 0 self.mx = self.speed self.add_point_to_path(self.rect.center) if self.sounds: SOUNDS.play_fx(11)