diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-07-26 16:24:26 +0300 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-07-26 16:24:26 +0300 |
| commit | b9fc3238fe84ba848b016cb2228ec597d242e2de (patch) | |
| tree | 2daa171c037315432811466530de146ce2dff08f | |
| parent | 70338d3ea32a3e62df4bbd0ab80bc8566278719e (diff) | |
Fixed logic with bug pathfinding
| -rw-r--r-- | src/main.zig | 15 |
1 files 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; - } } } |
