From ab20683e387d5ef09d52d1647492e819bf93380b Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Sat, 15 Nov 2025 11:48:27 -0500 Subject: graphics: add astar paths to debug rendering --- graphics/src/render.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'graphics/src/render.rs') diff --git a/graphics/src/render.rs b/graphics/src/render.rs index cc9847e..8202e49 100644 --- a/graphics/src/render.rs +++ b/graphics/src/render.rs @@ -278,6 +278,9 @@ impl Renderer { let camera = dungeon.render_camera(); let mut rc = r.begin_mode2D(camera); self.draw_bg_tilemap(&mut rc); + if self.debug { + rc.draw_pathing_deug(dungeon); + } self.draw_entities(&mut rc, dungeon); self.draw_fg_tilemap(&mut rc); } @@ -952,5 +955,27 @@ where ) { self.draw_rectangle(x.into(), y.into(), width.into(), height.into(), color); } + + fn draw_pathing_deug(&mut self, dungeon: &Dungeon) { + for enemy in &dungeon.enemies { + let Some(ai) = enemy.get_ai() else { + continue; + }; + let Some(moves) = ai.moves() else { + continue; + }; + for pos in moves { + let (x, y) = pos.xy(); + let color = Color::RED.alpha(0.5); + self.draw_rectangle_ext( + x * TILE_SIZE, + y * TILE_SIZE, + TILE_SIZE, + TILE_SIZE, + color, + ); + } + } + } } impl RaylibDrawExt for T where T: RaylibDraw {} -- cgit v1.2.3-freya