You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi ! I have a project where I try to implement the perlin noise with this lib and hexagonal tiles in a chunk way.
I am having trouble with 3 main issues and I would love to get help on any of these ones :
1. Cleaner way of creating the map
My code looks gross as i'm new to Rust but I was wondering if there was another way of setting up tiles
PS: I used the hexagonal_row example for this but couldn't find what I was looking for in any other example.
my set_tile.rs
let quadrant_size = TilemapSize{x:QUADRANT_SIDE_LENGTH,y:QUADRANT_SIDE_LENGTH,};let chunk_size = TilemapSize{x:QUADRANT_SIDE_LENGTH*2,y:QUADRANT_SIDE_LENGTH*2,};letmut tile_storage = TileStorage::empty(chunk_size);let tilemap_entity = commands.spawn_empty().id();let tilemap_id = TilemapId(tilemap_entity);
commands.entity(tilemap_id.0).with_children(|parent| {for x in0..quadrant_size.x{for y in0..quadrant_size.y{let pos = TilePos::new(x, y);let temp = temp[pos.to_index(&size)];let moist = moist[pos.to_index(&size)];let alt = alt[pos.to_index(&size)];// Oceanif alt < 0.{let tile_entity = parent
.spawn(TileBundle{position: pos,
tilemap_id,texture_index:TileTextureIndex(20),
..Default::default()}).id();
tile_storage.set(&pos, tile_entity);continue;}// Beachelseif alt > 0.0 && alt < 0.05{let tile_entity = parent
.spawn(TileBundle{position: pos,
tilemap_id,texture_index:TileTextureIndex(30),
..Default::default()}).id();
tile_storage.set(&pos, tile_entity);continue;}// Imagine this going for every biome, the functions just goes on forever
I was looking for a solution like create a variable, push the tile to the variable and then call a function that builds the map.
2. Deleting the map (FIXED)
I've tried a few things (mainly from all the examples) but couldn't figure out how to delete the map. I have a function that is supposed to do it but I get nothing :
pubfndespawn_map(mutcommands:Commands,muttilemap_query:Query<&mutTileStorage>,keyboard_input:Res<Input<KeyCode>>,){if keyboard_input.just_pressed(KeyCode::Space){formut tile_storage in tilemap_query.iter_mut(){// Remove all previously spawned tiles.for entity_option in tile_storage.iter_mut(){ifletSome(entity) = entity_option {println!("Despawning entity: {:?}", entity);
commands.entity(*entity).despawn_recursive();}}}}}
EDIT: It was easier than I expected, i just did it like that :
pubfndespawn_map(mutcommands:Commands,muttilemap_query:Query<Entity,With<TileStorage>>){for entity in tilemap_query.iter_mut(){
commands.entity(entity).despawn_recursive();}}
3. bevy-inspector-egui throws errors
The other issue I have is with bevy-inspector-egui where the tiles take a long time to load + I get errors like :
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi ! I have a project where I try to implement the perlin noise with this lib and hexagonal tiles in a chunk way.
I am having trouble with 3 main issues and I would love to get help on any of these ones :
1. Cleaner way of creating the map
My code looks gross as i'm new to Rust but I was wondering if there was another way of setting up tiles
PS: I used the hexagonal_row example for this but couldn't find what I was looking for in any other example.
my set_tile.rs
I was looking for a solution like create a variable, push the tile to the variable and then call a function that builds the map.
2. Deleting the map (FIXED)
I've tried a few things (mainly from all the examples) but couldn't figure out how to delete the map. I have a function that is supposed to do it but I get nothing :
3.
bevy-inspector-egui
throws errorsThe other issue I have is with
bevy-inspector-egui
where the tiles take a long time to load + I get errors like :For reference, here is my dependencies :
Beta Was this translation helpful? Give feedback.
All reactions