Adding a map creation plugin #57

Merged
CoCo_Sol merged 39 commits from map-generation into main 2024-02-21 20:10:03 +00:00
Showing only changes of commit 34557956e4 - Show all commits

View file

@ -10,7 +10,7 @@ use super::{Tile, TilePosition};
pub struct MapGenerationPlugin; pub struct MapGenerationPlugin;
/// The zoom of the map during the generation. /// The zoom of the map during the generation.
const MAP_GENERATION_ZOOM: f32 = 5.; const MAP_GENERATION_SCALE: f32 = 5.;
impl Plugin for MapGenerationPlugin { impl Plugin for MapGenerationPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
@ -75,7 +75,7 @@ fn generate_map(
/// Returns the type of the [HexPosition] with the given noise. /// Returns the type of the [HexPosition] with the given noise.
fn get_tile_type(position: HexPosition<i32>, noise: &Perlin) -> Tile { fn get_tile_type(position: HexPosition<i32>, noise: &Perlin) -> Tile {
let pixel_position = position.to_pixel_coordinates() / MAP_GENERATION_ZOOM; let pixel_position = position.to_pixel_coordinates() / MAP_GENERATION_SCALE;
let value = noise.get([pixel_position.x as f64, pixel_position.y as f64]); let value = noise.get([pixel_position.x as f64, pixel_position.y as f64]);
match value { match value {
v if v <= -0.4 => Tile::Hill, v if v <= -0.4 => Tile::Hill,