Skip to content

Commit

Permalink
Adds marker component for border tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mnmaita committed Nov 14, 2023
1 parent c1593f3 commit 29a7eba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn generate_level(mut commands: Commands) {
let translation = position.extend(0.0);
let transform = Transform::from_translation(translation);

commands.spawn(TileBundle {
let mut tile_entity = commands.spawn(TileBundle {
sprite: SpriteBundle {
sprite: Sprite {
color,
Expand All @@ -55,10 +55,17 @@ fn generate_level(mut commands: Commands) {
},
tile,
});

if y == 0 || x == 0 || y == GRID_SIZE.y as i32 - 1 || x == GRID_SIZE.x as i32 - 1 {
tile_entity.insert(BorderTile);
}
}
}
}

#[derive(Component)]
struct BorderTile;

#[derive(Bundle)]
pub struct TileBundle {
pub sprite: SpriteBundle,
Expand Down

0 comments on commit 29a7eba

Please sign in to comment.