ursina_tutorials
ursina_tutorials copied to clipboard
I added trees, here is a screenshot and the code!

Some things to note is that, I wasn't satisfied with how you made stepping noises, so I made a block type dictionary (self.bd). I also used a second Perlin Noise algorithm to make tree generation faster, less bugged, and re-creatable.
def gen_tree(self, px, py, pz, minHeight, maxHeight, leafValue, adult):
height = randint(minHeight, maxHeight)
leafOffset = floor(leafValue * 0.5)
chance = 1
if adult == True:
for x in range(2):
for y in range(height):
for z in range(2):
if self.td.get((px + x - 1, py + y, pz + z - 1)) != 't':
self.gen_block(px + x - 1, py + y, pz + z - 1, blockType = 'log', built = True)
else:
for i in range(height):
if self.td.get((px, py + i, pz)) != 't':
self.gen_block(px, py + i, pz, blockType = 'log', built = True)
for x in range(leafValue):
for y in range(leafValue):
for z in range(leafValue):
if self.td.get((px + x - leafOffset, py + height + y - leafOffset, pz + z - leafOffset)) != 't':
self.gen_block(px + x - leafOffset, py + height + y - leafOffset, pz + z - leafOffset, blockType = 'leaves', built = True)
THIS IS AWESOME!!!!!