From 3e57761c59dd39d79b790ffb0efd21902230f7db Mon Sep 17 00:00:00 2001 From: mnmaita <47983254+mnmaita@users.noreply.github.com> Date: Wed, 15 Nov 2023 00:10:52 +0100 Subject: [PATCH] Adds debug drawing system for the tile grid --- src/level.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/level.rs b/src/level.rs index cf87b4c..3bb8b2b 100644 --- a/src/level.rs +++ b/src/level.rs @@ -14,6 +14,30 @@ pub struct LevelPlugin; impl Plugin for LevelPlugin { fn build(&self, app: &mut App) { app.add_systems(OnEnter(AppState::InGame), generate_level); + + #[cfg(debug_assertions)] + { + app.add_systems(Update, debug_draw_tiles.after(generate_level)); + } + } +} + +#[cfg(debug_assertions)] +fn debug_draw_tiles( + query: Query<(&Transform, Option<&BorderTile>), With>, + mut gizmos: Gizmos, +) { + for (transform, border_tile) in &query { + gizmos.rect_2d( + transform.translation.truncate(), + 0., + TILE_SIZE, + if border_tile.is_some() { + Color::BLACK + } else { + Color::FUCHSIA + }, + ); } }