An issue with trees and event sequences.

Discussion and feedback on Construct 2

Post » Wed Feb 06, 2013 6:36 am

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

Thanks in advance for any thoughts/advice,
~AdamObsidianSpoon2013-02-06 06:37:19
Posts: 1
Reputation: 277

Post » Wed Feb 06, 2013 6:38 am

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...
Posts: 1,833
Reputation: 14,548

Post » Wed Feb 06, 2013 6:57 am

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.vee412013-02-06 08:47:03
Posts: 756
Reputation: 7,292

Return to Construct 2 General

Who is online

Users browsing this forum: Colludium, R0J0hound, TheRealDannyyy and 8 guests