Procedurally Generated Plants and Trees?

0 favourites
  • 8 posts
From the Asset Store
25 high-quality predatory plants. This asset is perfect for a side scrolling game, or even a turn based RPG type game.
  • 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

  • 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

  • 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..

  • 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!

  • 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.

  • 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. :)

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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. :)

    <img src="http://www.80bit.com/pic/Windows_7-20131204-081220.jpg" border="0" />

Jump to:
Active Users
There are 2 visitors browsing this topic (0 users and 2 guests)