From b9fc3238fe84ba848b016cb2228ec597d242e2de Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Sat, 26 Jul 2025 16:24:26 +0300 Subject: Fixed logic with bug pathfinding --- src/main.zig | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main.zig b/src/main.zig index 0a15a6b..ac29563 100644 --- a/src/main.zig +++ b/src/main.zig @@ -98,7 +98,6 @@ const Bug = struct { const lane_left = wave.get(target_grid_x - 1, target_grid_y).isLaneConnected(); const lane_right = wave.get(target_grid_x + 1, target_grid_y).isLaneConnected(); - // TODO: are these correct or flipped const lane_top = wave.get(target_grid_x, target_grid_y - 1).isLaneConnected(); const lane_bottom = wave.get(target_grid_x, target_grid_y + 1).isLaneConnected(); @@ -122,26 +121,24 @@ const Bug = struct { std.debug.print("lane right\n", .{}); } if (lane_top and prev_grid_y != target_grid_y - 1) { - // TODO: are these correct or flipped target = self.target.add(rl.Vector2.init(0, -cell_size)); std.debug.print("lane top\n", .{}); } if (lane_bottom and prev_grid_y != target_grid_y + 1) { - // TODO: are these correct or flipped target = self.target.add(rl.Vector2.init(0, cell_size)); std.debug.print("lane bottom\n", .{}); } if (target.x == 0 and target.y == 0) { - unreachable; + if (wave.get(target_grid_x, target_grid_y) == .ram) { + ram.* = @max(ram.* - self.damage(), 0); + self.dead = true; + } else { + unreachable; + } } self.previous = self.target; self.target = target; - - if (wave.get(target_grid_x + 1, target_grid_y) == .ram) { - ram.* = @max(ram.* - self.damage(), 0); - self.dead = true; - } } } -- cgit v1.3.1