An issue with trees and event sequences.

0 favourites
  • 3 posts
From the Asset Store
77 Hi-Res realistic Trees over transparent background. Variety of species and seasons.
  • Hi, so I'm brand new to Construct 2 and the forums. I apologize if this topic is covered elsewhere, but I couldn't find it.

    I've spent all day teaching myself how this program works, and have built a little system to test some things. Now, I'm stumped. When I run my program, I want it to generate a forest by randomly placing trees, then placing more in relation to the ones already there, and finally, I want the tree images to be drawn from a pool of 5 images. I've got all that to work, more or less. My questions are A) is there a way to speed up this process or a more efficient way to do it (I load every tree, then change the animation frame to a random one), and 2) is there a way to layer the objects so the ones with a lower y coord. will be above the objects with a higher y coord. (on the z axis), making the trees look like each one is behind the one in front of it, rather than just a pile of trees on top of each other?

    Here's my project file so you can see what I'm doing...

    dropbox.com/s/u1f295gwrousiq0/Trees.capx

    Thanks in advance for any thoughts/advice,

    ~Adam

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I can't open the CAPX files right now as I am on the wrong computer, but for the Z order couldn't you place them on different layers? It might be easier than adjusting their z order based on where they are relative to another tree...

  • Here is what I came up with:

    Forest generation

    Mostly just tidied up what you did (it had few bugs that caused some unintended behavior), it's a really cool system you got :)

    I removed some of the looping, added some variables for control, made trees be destroyed outside the layout + some minor tuning. Also made them not overlap, which causes most of the slowness here, you can tinker that if you wish :)

    EDIT: Just noticed your second question, that's how carefully I read peoples posts... :P

    Anyway, added an event to handle the Z order as well. Basically after all trees have been generated we go through them in order of their Y position and send them to bottom of the layer.

    EDIT2: Few notes on performance; you could try creating 1000 trees in editor and set their position in events instead of spawning new ones during execution, might be quicker. And if you do not want the player to see threes going swooshswooshswoosh during generation you could add a loading screen that you hide after the map has been generated.

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