mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-10 01:28:41 -06:00
experimenting a bit more
This commit is contained in:
parent
ed5b8de09a
commit
37ab56115f
|
@ -6,6 +6,9 @@ use crate::game::{
|
|||
};
|
||||
|
||||
const HEIGHTMAP_SCALE: f64 = 0.004;
|
||||
const MOUNTAINESS_SCALE: f64 = 0.0001;
|
||||
const MNT_RAMP_1: f64 = 0.5;
|
||||
const MNT_RAMP_2: f64 = 0.6;
|
||||
const TERRAIN_HEIGHT_MIN: f64 = 64.;
|
||||
const TERRAIN_HEIGHT_MAX: f64 = 80.;
|
||||
|
||||
|
@ -17,14 +20,31 @@ pub fn generate_chunk(position: IVec2, seed: u32) -> ChunkData {
|
|||
let mut terrain_base_fbm: Fbm<Perlin> = Fbm::new(seed);
|
||||
terrain_base_fbm.octaves = 6;
|
||||
|
||||
let mut mountainess_base_fbm: Fbm<Perlin> = Fbm::new(seed);
|
||||
mountainess_base_fbm.octaves = 4;
|
||||
|
||||
//put everything together
|
||||
for x in 0..CHUNK_SIZE {
|
||||
for z in 0..CHUNK_SIZE {
|
||||
let point = world_xz.as_dvec2() + DVec2::from_array([x as f64, z as f64]);
|
||||
|
||||
let heightmap = (terrain_base_fbm.get((point * HEIGHTMAP_SCALE).to_array()) + 1.) / 2.;
|
||||
let mountainess = (mountainess_base_fbm.get((point * MOUNTAINESS_SCALE).to_array()) + 1.) / 2.;
|
||||
|
||||
//generate basic terrain
|
||||
let terain_height = (TERRAIN_HEIGHT_MIN + (heightmap * TERRAIN_HEIGHT_MAX)).floor() as usize;
|
||||
let terain_height =
|
||||
(
|
||||
TERRAIN_HEIGHT_MIN +
|
||||
(heightmap * TERRAIN_HEIGHT_MAX * (1. + if mountainess < MNT_RAMP_1 {
|
||||
0.
|
||||
} else {
|
||||
if mountainess > MNT_RAMP_2 {
|
||||
1.
|
||||
} else {
|
||||
mountainess - MNT_RAMP_1
|
||||
}
|
||||
}))
|
||||
).floor() as usize;
|
||||
for y in 0..terain_height {
|
||||
chunk[x][y][z] = Block::Dirt;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue