even better trees

This commit is contained in:
griffi-gh 2023-02-16 04:08:00 +01:00
parent f9b4628b49
commit 4a84fec041

View file

@ -120,11 +120,13 @@ pub fn generate_world(chunk_position: IVec3, seed: u64) -> (BlockData, Vec<Queue
for tree_y in 0..tree_height { for tree_y in 0..tree_height {
smart_place(&mut blocks, tree_pos + IVec3::Y * tree_y, Block::Wood); smart_place(&mut blocks, tree_pos + IVec3::Y * tree_y, Block::Wood);
} }
// Part that wraps around the tree
{
let tree_leaf_height = tree_height - 3; let tree_leaf_height = tree_height - 3;
let tree_width = 2; let leaf_width = 2;
for tree_y in tree_leaf_height..tree_height { for tree_y in tree_leaf_height..tree_height {
for tree_x in (-tree_width)..=tree_width { for tree_x in (-leaf_width)..=leaf_width {
for tree_z in (-tree_width)..=tree_width { for tree_z in (-leaf_width)..=leaf_width {
let tree_offset = ivec3(tree_x, tree_y, tree_z); let tree_offset = ivec3(tree_x, tree_y, tree_z);
if tree_offset.xz() == IVec2::ZERO { continue } if tree_offset.xz() == IVec2::ZERO { continue }
smart_place(&mut blocks, tree_pos + tree_offset, Block::Leaf); smart_place(&mut blocks, tree_pos + tree_offset, Block::Leaf);
@ -132,6 +134,20 @@ pub fn generate_world(chunk_position: IVec3, seed: u64) -> (BlockData, Vec<Queue
} }
} }
} }
//part above the tree
{
let leaf_above_height = 2;
let leaf_width = 1;
for tree_y in tree_height..(tree_height + leaf_above_height) {
for tree_x in (-leaf_width)..=leaf_width {
for tree_z in (-leaf_width)..=leaf_width {
let tree_offset = ivec3(tree_x, tree_y, tree_z);
smart_place(&mut blocks, tree_pos + tree_offset, Block::Leaf);
}
}
}
}
}
} }
} }
} }