Random Tree Generator

Post your own tutorials, guides and demos.

Post » Sun Mar 28, 2010 7:38 am

I'm working on a platform game, and recently came across the idea of a random tree generator. Realizing that this could provide a really interesting look to my backgrounds, I thought it'd be fun to try to build one myself, but holy cow do I not know where to begin. Any ideas?
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Sun Mar 28, 2010 1:45 pm

first off, make posts about getting help, in the HELP forum. your tutorials is made for tutorials obviously.

where to start?

well first off, do you know about the random expression?
random(VALUE) it a random number between 0 and what you input. remember that if you put a number, its not going to ever return the number you gave, but instead integer every number below it including 0. so random(10) would give you 0,1,2,3,4,5,6,7,8,9 but never 10.

after you know about that expression your gonna need an object for branches, that you spawn and then at its end you spawn more branches, always setting theyre length and angle to a random value.

then youd need some cutoff point and a leaf spawner. not gonna go into anymore detail you figure it out!
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Sun Mar 28, 2010 3:49 pm

B
3
G
3
Posts: 15
Reputation: 905

Post » Sun Mar 28, 2010 4:23 pm

Well I had this all wrong. I thought he wanted random trees for a side scroll-er. In that case I would have used the same tree and and had the game do the random(VALUE) as QuaziGNRLnose suggested and then have random sizes of the same tree.

Nice example SacceuS.
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Mon Mar 29, 2010 12:46 am

Thanks for the help guys, this is the idea, for sure, something I can use to generate different looking trees randomly, and then be able to use them in the background of a platformer. Sorry about posting in the wrong section, I'm still somewhat new to forums.
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Mon Mar 29, 2010 5:10 am

[url:in8vqvv2]http://vlab.infotech.monash.edu.au/tutorials/l-systems/[/url:in8vqvv2]

I've thought about using L-systems to make a screensaver, just haven't gotten around to it, hope that helps.
B
2
S
2
G
3
Posts: 114
Reputation: 1,553

Post » Mon Mar 29, 2010 5:14 am

Wow, that's intense, but I'll be sure to give it a good read
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Mon Mar 29, 2010 8:32 pm

so I'm reading about l-systems, and they're starting to make sense, but how do I implement them in Construct?
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Wed Mar 31, 2010 11:06 am

Weird. I hadn't seen this thread, but I started making random trees the same day it kicked off.

I was using an approach like the one Quazi was talking about - branches spawn smaller branches until you have a tree (using randomisation at each step).

Here's the cap:
http://dl.dropbox.com/u/906550/Construct/noise6.cap

And EXE, in case you have an older version (I'm on .84, the latest):
http://dl.dropbox.com/u/906550/Construct/noise6.exe

Press Q to grow the trees by one step. You should probably stop after about 8-12 steps, because the number of branches increases exponentially.

I haven't gotten foliage working yet. I had something that looked reasonably good, but it's ridiculously resource-intensive (and so I ended up having to paste it into a Canvas object after, which really reduces the amount of stuff like wind effects you could do). A lot of the fractal trees I've seen in 3d actually used a very similar method to make the foliage after the branches were done, so I might try that.

(If you like how this approach looks and want to use it, I'll see if I can make up a cleaner .cap so you can see how it works - there's a lot of crappy, leftover, and unrelated eventing in the current one.)
B
5
S
2
G
4
Posts: 113
Reputation: 2,101

Post » Thu Apr 01, 2010 2:42 pm

your cap looks very cool, I'll be sure to have a better look at the workings and see what I can learn from it. Ultimately, what I want is to be able to have a set of randomized variables to control things like tree type, branch placement, foliage colour, bark colour, and things like that. But this looks like a good start for sure.
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Next

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 0 guests