extends RefCounted ## Tables and target rules are based on https://pacman.holenet.info/. const SCATTER := [Vector2i(25, -3), Vector2i(2, -3), Vector2i(27, 32), Vector2i(0, 32)] const FRIGHT := [6.0, 5.0, 4.0, 3.0, 2.0, 5.0, 2.0, 2.0, 1.0, 5.0, 2.0, 1.0, 1.0, 3.0, 1.0, 1.0, 0.0, 1.0] static func frightened_seconds(level: int) -> float: return FRIGHT[level - 1] if level <= FRIGHT.size() else 0.0 static func schedule(level: int) -> Array: if level == 1: return [7.0, 20.0, 7.0, 20.0, 5.0, 20.0, 5.0, INF] return [7.0 if level < 5 else 5.0, 20.0, 7.0 if level < 5 else 5.0, 20.0, 5.0, 1033.0 if level < 5 else 1037.0, 1.0 / 60.0, INF] static func target(index: int, player_tile: Vector2i, direction: Vector2i, blinky: Vector2i, ghost_tile: Vector2i) -> Vector2i: match index: 0: return player_tile 1: return player_tile + direction * 4 + (Vector2i.LEFT * 4 if direction == Vector2i.UP else Vector2i.ZERO) 2: var ahead := player_tile + direction * 2 + (Vector2i.LEFT * 2 if direction == Vector2i.UP else Vector2i.ZERO) return ahead * 2 - blinky _: return player_tile if Vector2(ghost_tile).distance_squared_to(Vector2(player_tile)) >= 64.0 else SCATTER[3] static func elroy_threshold(level: int) -> int: if level == 1: return 20 if level == 2: return 30 if level <= 5: return 40 if level <= 8: return 50 if level <= 11: return 60 if level <= 14: return 80 if level <= 18: return 100 return 120 static func fruit_index(level: int) -> int: return mini(7, int(level / 2.0)) static func fruit_score(level: int) -> int: return [100, 300, 500, 700, 1000, 2000, 3000, 5000][fruit_index(level)]