Create a tree depending on level

What's problem you are encountering?
I'm trying to create a treet depending on the level given, I can make it work with 2 and 3 and I'm unable to make it work with 4. It should create 4 branches for 4 levels

Looks good. Could you post a link to your project? Thanks! (And welcome to the forum!)

Hello, please how do I share the project?

In Snap! itself, say control-O or select "Open" from the file menu. Then select the project you want to share. Then click the "Share" button down at the bottom of the window. Finally, copy the URL from the browser's URL bar and paste it here,

Here is the link

Yeah, it totally works. Your green-flag script says to make a level-3 tree. If you change that to level 4, you'll get four sizes of line segment.


(although I think you meant to put the TREE block at the bottom):
tree_final script pic

It does work but the things are clamping.

Thank you, level 1 should always to be 1 but from level 2 depending on the input the branches and subbranches should change, for example I pass 4 the should be 4 branches and 4 subbranches for each branch

Oh. No, you don't understand your own code. (Are you a BJC student?)

The level number specifies how many times the tree branches -- in effect, it determines the height of the tree.

But you have three recursive calls to TREE, so each branching makes three of what you're calling subbranches.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.