Tree animation

by Jens
See inside

Press the green flag and watch the Scratch cat forever draw a tree with changing angles.

Notes and Credits

For this project I've created a custom block which draws the tree. The "tree" block has several inputs, and only runs its code if the input named "level" isn't zero. At two points in its script, the "tree" block has a copy of itself! This is called (branching) "recursion". Note how when calling itself, it decreases the "level" input. Now you understand why at the beginning of the script the block checks whether the level isn't zero. This is called the "base case", and makes sure that the block doesn't go on forever.

Recursion is one of the coolest features of Scratch 2.0!

In the block's options I've decided to let it "Run without screen refresh", so the tree is drawn all at once. This way clearing the stage, and re-drawing it with a different angle creates the illusion of something actually moving, an animation.

Shared: 28 Jan 2013 Modified: 25 Feb 2015
Favorite this project 11
Love this project 39
Total views 529
View the remix tree  11
More projects by Jens