Randomly Generating Animated Trees

Randomly Generating Trees

Trees are found all around the world yet none look quite exactly the same. Games like The Long Dark or Firewatch both take place in environments filled with trees. Having different styles for trees is crucial in games like these to avoid making the game look dull or boring. Including different variations of certain things can be very important in making a game feel more professional whether the variations be randomly generated or from a man-made set.

To start off with creating trees with code you have to figure out what you could compare them to, this happens to be what’s known as fractals. Fractals are immensely complicated abstract objects that typically resemble objects found in nature. The image below shows a fractal that looks similar to a tree.

Here’s a program that generates random fractal-like trees. This program creates trees based off of random values such as: the number of break-offs, the number of branches that grow from each break-off, how much the branches spread apart, etc. It then creates new branches based off of these values and once it hits the end of the branch it adds a “leaf”. You can test it down below or find it at: https://www.ktbyte.com/projects/project/73151.

After going through the example you should try changing the variables up to create different styles of trees or possibly trying to create other plants like flowers, bushes, etc. This could be done by editing the colors, changing the branch sizes and other small tweaks like these.

Leave a Reply

Your email address will not be published. Required fields are marked *