This commit is contained in:
CoCo_Sol 2024-02-20 12:16:05 +01:00
parent 07ffb9e45c
commit acd2de265c

View file

@ -52,17 +52,17 @@ fn generate_map(
if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) { if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) {
if let Some(position) = spiral.next() { if let Some(position) = spiral.next() {
let pixel_position = position.to_pixel_coordinates((0.2, 0.2)); let pixel_position = position.to_pixel_coordinates((0.2, 0.2));
commands.spawn((get_type_tile(pixel_position, perlin), position)); commands.spawn((get_type(pixel_position, perlin), position));
} else { } else {
end_map_event.send(EndMapGeneration); end_map_event.send(EndMapGeneration);
*noise = None; *noise = None;
*map_iterator = None; *map_iterator = None;
} }
} }
} }
/// Returns the type of the tile at the given position with the given noise. /// Returns the type of the position with the given noise.
fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile { fn get_type(position: (f32, f32), noise: &Perlin) -> Tile {
let value = noise.get([position.0 as f64, position.1 as f64]); let value = noise.get([position.0 as f64, position.1 as f64]);
match value { match value {
v if v <= -0.4 => Tile::Hill, v if v <= -0.4 => Tile::Hill,