From ec3185f386869614e0ab90b6df8cb879f8b3b0fc Mon Sep 17 00:00:00 2001 From: GarandPLG Date: Tue, 18 Nov 2025 18:13:17 +0100 Subject: [PATCH] Add base tilemap layer with specific tile regions --- src/main.rs | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 33151bf..cf265d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,8 +11,10 @@ fn startup(mut commands: Commands, asset_server: Res) { let base_texture_handle: Handle = asset_server.load("base_field.png"); let tilemap_entity = commands.spawn_empty().id(); + let base_tilemap_entity = commands.spawn_empty().id(); let mut tile_storage = TileStorage::empty(MAP_SIZE); + let mut base_tile_storage = TileStorage::empty(MAP_SIZE); for x in 0..MAP_SIZE.x { for y in 0..MAP_SIZE.y { @@ -28,6 +30,38 @@ fn startup(mut commands: Commands, asset_server: Res) { } } + for x in 0..5 { + for y in 10..15 { + if x < MAP_SIZE.x && y < MAP_SIZE.y { + let tile_pos = TilePos { x, y }; + let tile_entity = commands + .spawn(TileBundle { + position: tile_pos, + tilemap_id: TilemapId(base_tilemap_entity), + ..Default::default() + }) + .id(); + base_tile_storage.set(&tile_pos, tile_entity); + } + } + } + + for x in 45..50 { + for y in 10..15 { + if x < MAP_SIZE.x && y < MAP_SIZE.y { + let tile_pos = TilePos { x, y }; + let tile_entity = commands + .spawn(TileBundle { + position: tile_pos, + tilemap_id: TilemapId(base_tilemap_entity), + ..Default::default() + }) + .id(); + base_tile_storage.set(&tile_pos, tile_entity); + } + } + } + commands.entity(tilemap_entity).insert(TilemapBundle { grid_size: TILE_SIZE.into(), map_type: TilemapType::default(), @@ -36,6 +70,19 @@ fn startup(mut commands: Commands, asset_server: Res) { texture: TilemapTexture::Single(dirt_texture_handle), tile_size: TILE_SIZE, anchor: TilemapAnchor::Center, + transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)), + ..Default::default() + }); + + commands.entity(base_tilemap_entity).insert(TilemapBundle { + grid_size: TILE_SIZE.into(), + map_type: TilemapType::default(), + size: MAP_SIZE, + storage: base_tile_storage, + texture: TilemapTexture::Single(base_texture_handle), + tile_size: TILE_SIZE, + anchor: TilemapAnchor::Center, + transform: Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)), ..Default::default() }); } @@ -57,6 +104,5 @@ fn main() { ) .add_plugins(TilemapPlugin) .add_systems(Startup, startup) - // .add_systems(Update, helpers::camera::movement) .run(); }