Procedurally Generated Plants and Trees?

Get help using Construct 2

Post » Sun Dec 01, 2013 11:06 pm

I was hoping to do some procedurally generated plants / trees in my game, but I have a few criteria:

1) I need to be able to control the points of growth only because:
2) I need to remember the intersection points so I can place 'leaf' sprites & berries on them.

I was thinking of doing the first part via canvas, by generating tree arrays containing the growth points, then drawing (over time) the lines to the points of growth.

The thing is, in my experimentation with Canvas, it seems having multiple instance of one canvas will draw the same thing on all instances, even in a foreach scenario. So im wondering: do I make one bigass canvas the dimensions of my entire layout (20,000 x 20,000 layout tho...) or will that cause some intense performance issues? Is there a nicer way to do it? If im drawing thousands and thousands of little branch sprites will that effect performance? I guess i should just get down to testing but I thought id see what you guys thought before i went too far down a dead end, in case you've dealt with this already.

as always - infinite thank you's. :)

Hugs, nate
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
27
S
8
G
3
Posts: 384
Reputation: 5,020

Post » Mon Dec 02, 2013 10:28 am

Objects off-screen are not rendered, if i recall correctly, therefore you should have better performance with many little objects instead of one huge.
Also, can't you give each canvas an unique id and add a check in the conditions and thus prevent doing actions for all of them?

20'000x20'000 pixel layout? Thousands of sprites being drawn and modified at the same time? You should be just fine, just make that the sprites are in HD! However, you might have to pause the real-time simulation of the entire universe running in the background to get silky smooth 60 fps on that NASA super computer of yours. Also, while you are at it, say hi to the Primarch system for me, will you? /s
B
10
S
1
Posts: 163
Reputation: 1,436

Post » Mon Dec 02, 2013 10:47 am

If I'm correct a 20000x20000 canvas object would be rendered as a 20000x20000 sprite, which would take about 20000x20000x4 = 1600.000.000 bytes = 1600 MB of graphic memory..

But math wasn't my best subject at school, so I might be mistaken..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Dec 03, 2013 2:24 am

Thank you guys! You confirmed my suspicions. I thought a lot about it and i think im just going to draw a bunch of cool looking stylized sprites. May as well stop being so lazy and put the art training to good use. :P Thanks again!
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
27
S
8
G
3
Posts: 384
Reputation: 5,020

Post » Tue Dec 03, 2013 6:35 am

Just a follow up question. Were you trying to create a plugin or use Rojo hounds Canvas plugin?

If went with procedure tree's. I would suggest a plugin instead.
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

Post » Tue Dec 03, 2013 10:51 pm

I was trying to use the canvas plugin actually, i was getting the drawing nicely but i needed to have a separate instance to each tree anyway, so for hundreds of trees, i may as well just use sprites and im using a separate animation for each tree, then choosing the animation randomly at the time of generation & "growing" the tree over time as it exists by setting the animation frame every 100 seconds or whatever. works nice, just no smooth animation, but it lets me have more cool looking illustrated trees anyway. :)
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
27
S
8
G
3
Posts: 384
Reputation: 5,020

Post » Tue Dec 03, 2013 10:55 pm

Well I'm glad it's working out. Do you have any samples of a generated tree. I woldn't mind seeing it and seeing the code behind them :)

And just out of curiosity. It sounds like you saying that your using the official Canvas Plugin; where as C2 doesn't have one. So I'm assuming you used Rojohounds. I think Rojohounds canvas was meant for a replacement drawable background and not an individual sprite replacement.
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

Post » Wed Dec 04, 2013 4:13 pm

My bad, sorry - you're right - Rojohounds is the one im using. Here's some of my code for the tree generation. Im no pro, so this is probably horrible. :D Just doing the best I can. :)

Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
27
S
8
G
3
Posts: 384
Reputation: 5,020


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests