use bevy::prelude::*; use bevy_ecs_tilemap::helpers::square_grid::neighbors::Neighbors; use bevy_ecs_tilemap::prelude::*; mod helpers; fn startup(mut commands: Commands, asset_server: Res) { commands.spawn(Camera2dBundle::default()); let texture_handle: Handle = asset_server.load("tiles.png"); let map_size = TilemapSize { x: 32, y: 32 }; let mut tile_storage = TileStorage::empty(map_size); let tilemap_entity = commands.spawn_empty().id(); let mut i = 0; for x in 0..map_size.x { for y in 0..map_size.y { let tile_pos = TilePos { x, y }; let tile_entity = commands .spawn(TileBundle { position: tile_pos, tilemap_id: TilemapId(tilemap_entity), visible: TileVisible(i % 2 == 0 || i % 7 == 0), ..Default::default() }) .id(); tile_storage.set(&tile_pos, tile_entity); i += 1; } } let tile_size = TilemapTileSize { x: 16.0, y: 16.0 }; let grid_size = tile_size.into(); let map_type = TilemapType::Square; commands.entity(tilemap_entity).insert(( TilemapBundle { grid_size, map_type, size: map_size, storage: tile_storage, texture: TilemapTexture::Single(texture_handle), tile_size, transform: get_tilemap_center_transform(&map_size, &grid_size, &map_type, 0.0), ..Default::default() }, LastUpdate(0.0), )); } #[derive(Component)] pub struct LastUpdate(f64); fn update( mut commands: Commands, time: Res