Skip to content

Commit

Permalink
Adds debug drawing system for the tile grid
Browse files Browse the repository at this point in the history
  • Loading branch information
mnmaita committed Nov 14, 2023
1 parent 29a7eba commit 3e57761
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tile>>,
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
},
);
}
}

Expand Down

0 comments on commit 3e57761

Please sign in to comment.