Endless world, still some bugs to figure out

This commit is contained in:
Piotrek
2021-05-14 19:54:46 +02:00
parent e6329d568c
commit 00c518b9c1
9 changed files with 91 additions and 60 deletions
+12 -3
View File
@@ -42,19 +42,28 @@ impl WorldGen {
* Generate block
*/
pub fn generate(block_pos: &Vector3<i32>, block: &mut WorldBlock) {
if block_pos.z > 32 as i32 { return; }
let mut rng = rand::thread_rng();
let noise = Perlin::new();
// Generate height map
let (map, _max) = WorldGen::gen_height_map(block_pos.x, block_pos.z, &mut rng, &noise);
// Fill
for x in 0..block::SIZE {
for z in 0..block::SIZE {
let h = map[x][z];
let mut h = map[x][z];
let mut t = 2;
if block_pos.x == 8 && block_pos.z == 8 {
h = 32;
t = 3;
}
//let h = 16; // testing
for y in 0..h {
block.set(Vector3{x, y, z}, 2);
block.set(Vector3{x, y, z}, t);
}
}
}