diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-11-15 11:48:27 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-11-15 11:48:27 -0500 |
| commit | ab20683e387d5ef09d52d1647492e819bf93380b (patch) | |
| tree | 420c0eb27f7c56167291d3e57a61f790d21d4d01 /graphics/src/render.rs | |
| parent | dungeon: randomize floor brick accents (diff) | |
| download | DungeonCrawl-ab20683e387d5ef09d52d1647492e819bf93380b.tar.gz DungeonCrawl-ab20683e387d5ef09d52d1647492e819bf93380b.tar.bz2 DungeonCrawl-ab20683e387d5ef09d52d1647492e819bf93380b.zip | |
graphics: add astar paths to debug rendering
Diffstat (limited to 'graphics/src/render.rs')
| -rw-r--r-- | graphics/src/render.rs | 25 |
1 files changed, 25 insertions, 0 deletions
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<T> RaylibDrawExt for T where T: RaylibDraw {} |