Funny Trees
Let's plant some funny looking "trees", if you can call them trees. See the pictures first and laugh as you wish.
A wooden trunk in the middle, and two green leave lines at the left and right sides built with for
loops.
# funnyTree
for j in range(20):
block(0, j, -10, 'log_big_oak')
block(-1, j+10, -10, 'leaves')
block(1, j+10, -10, 'leaves')
😂
Let's try a different design: use shorter, dotted line for the leaves.
# 2DTree
for j in range(20):
block(10, j, -10, 'log_big_oak')
for l in range(10, 20, 2):
block(9, l, -10, 'leaves')
block(11, l+1, -10, 'leaves')
🤔
Next step, we will put leave blocks on the front and back sides too.
# 3DTree
for j in range(20):
block(15, j, -10, 'log_big_oak')
for l in range(10, 20, 2):
block(14, l, -10, 'leaves')
block(16, l+1, -10, 'leaves')
block(15, l, -11, 'leaves')
block(15, l+1, -9, 'leaves')
We've defined some functions to build columns and bars, let's use them to design trees.
Build a wooden column in the middle as tree trunk, then add three green bars at the top:
# call column(x,z,h,m), bar_y(x,y,z,l,m)
# tree2d, ever number h
column(0, -10, 10, 'log_big_oak')
for i in range(-1, 2):
bar_y(i, 10, -10, 8, 'leaves')
This "tree" looks more like a popsicle!
Let's make it 3D:
# tree3d
column(15, -10, 10, 'log_big_oak')
for i in range(14, 17):
for k in range(-11, -8):
bar_y(i, 10, -10, 8, 'leaves')
A more expensive popsicle!
Don't give up yet, we have better stuff in the next chapter!