From c16ad4f4a0f56c26da76a9b871d359bcd541c831 Mon Sep 17 00:00:00 2001 From: Piotrek Date: Thu, 6 May 2021 15:49:21 +0200 Subject: [PATCH] bug fixes --- src/app/mod.rs | 8 ++++++++ src/app/world/generator.rs | 4 ++-- src/app/world/mod.rs | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/mod.rs b/src/app/mod.rs index c2ce0ee..5b673e9 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -28,6 +28,14 @@ impl App { let block = app.world.gen_block(pos); content.write(pos, block); + let pos = &Point3{x:1,y:0,z:0}; + let block = app.world.gen_block(pos); + content.write(pos, block); + + let pos = &Point3{x:0,y:0,z:1}; + let block = app.world.gen_block(pos); + content.write(pos, block); + println!("App initialized"); app } diff --git a/src/app/world/generator.rs b/src/app/world/generator.rs index e1df591..cf63c43 100644 --- a/src/app/world/generator.rs +++ b/src/app/world/generator.rs @@ -49,8 +49,8 @@ impl WorldGen { // Fill for x in 0..block::SIZE { for z in 0..block::SIZE { - //let h = map[x][z]; - let h = 16; // testing + let h = map[x][z]; + //let h = 16; // testing for y in 0..h { block.set(Point3{x, y, z}, 2); } diff --git a/src/app/world/mod.rs b/src/app/world/mod.rs index 2440bf5..3e92d47 100644 --- a/src/app/world/mod.rs +++ b/src/app/world/mod.rs @@ -26,11 +26,11 @@ impl World { let ch_pos = block_pos / chunk::SIZE; let bl_pos = block_pos % chunk::SIZE; // Create chunk if does not exist - if let None = self.chunks.get_mut(&ch_pos) { + if let None = self.chunks.get(&ch_pos) { self.chunks.insert(block_pos.clone(), WorldChunk::new()); } // Generate block for chunk - let chunk = self.chunks.get_mut(block_pos).unwrap(); + let chunk = self.chunks.get_mut(&ch_pos).unwrap(); let block = chunk.get_block(&bl_pos); WorldGen::generate(&bl_pos, block); block