generated from tipragot/rust
Adding a map creation plugin #57
|
@ -51,7 +51,7 @@ 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)); // Réduire la taille de la tuile
|
let pixel_position = position.to_pixel_coordinates((0.2, 0.2));
|
||||||
commands.spawn((get_type_tile(pixel_position, perlin), position));
|
commands.spawn((get_type_tile(pixel_position, perlin), position));
|
||||||
} else {
|
} else {
|
||||||
end_map_event.send(EndMapGeneration);
|
end_map_event.send(EndMapGeneration);
|
||||||
|
@ -65,8 +65,8 @@ fn generate_map(
|
||||||
fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile {
|
fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile {
|
||||||
CoCo_Sol marked this conversation as resolved
|
|||||||
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.5 => Tile::Hill, // Réduire le seuil pour les collines
|
v if v <= -0.5 => Tile::Hill,
|
||||||
v if v >= 0.5 => Tile::Forest, // Réduire le seuil pour les forêts
|
v if v >= 0.5 => Tile::Forest,
|
||||||
_ => Tile::Grass,
|
_ => Tile::Grass,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue
This should be in the get_type function and the value shouldn't be hard coded