Random Spawning - Overlapping Check

Get help using Construct 2

Post » Fri Aug 16, 2013 1:27 am

Hey everyone, so I'm trying to randomly populate a layout with trees on the start of a layout, but I don't want any of them to be overlapping. Currently on the start of the layout I run a repeat action 1000 times that creates an object at a random (X,Y) position. This (obviously) creates 1000 trees all over the place, but many of them overlap.

I can't think how to tell them to not spawn in locations where they'd be overlapping with another object. I'd like to populate the world in a more interesting way later on with other scenery objects, and figuring this out will give me the foundations for that. But trees first. Any help would be appreciated, thanks!

Here's a link to the playable project over on dropbox to provide some context:

http://goo.gl/lwJpYj


WASD to move, click the trees to cut them, press I to open Inventory.Exuro2013-08-16 01:28:41
B
10
S
2
G
2
Posts: 12
Reputation: 1,709

Post » Fri Aug 16, 2013 1:53 am

Try moving a tree when it collides with another tree. I've made an example for you.
B
46
S
14
G
7
Posts: 603
Reputation: 8,106

Post » Fri Aug 16, 2013 2:52 am

Thanks for the quick response and the example, I haven't been able to open it up yet since apparently there's a newer version of Construct and my Steam hasn't picked it up, but I'll check it out when it's updated!

Edit: Ah I see, you're using the beta version. Will download it to check it out, thanks!Exuro2013-08-16 03:03:15
B
10
S
2
G
2
Posts: 12
Reputation: 1,709

Post » Fri Aug 16, 2013 5:57 am

Thanks for your help, here's what I got as a result:

https://dl.dropboxusercontent.com/u/12286612/Survival%20Sandbox%202/index.html
B
10
S
2
G
2
Posts: 12
Reputation: 1,709

Post » Fri Aug 16, 2013 11:33 am

What kind of device are u planning to run this on?
Tried the db link on my iPad, waited 2 min for generation, then gave up.
Will check the earlier capx when I get home
B
9
S
2
G
2
Posts: 59
Reputation: 1,024

Post » Fri Aug 16, 2013 12:09 pm

Here is an old example that also does forest generation. Play around with the variables for some funky results :)

Forest generation
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Post » Fri Aug 16, 2013 5:47 pm

[QUOTE=Hoyer] What kind of device are u planning to run this on?
Tried the db link on my iPad, waited 2 min for generation, then gave up.
Will check the earlier capx when I get home[/QUOTE]

I was planning to run it on PC, but to be honest it would probably be a good mobile game. I'll have to scale it down fairly significantly for mobile devices. It was running fine on my PC, but I tried running it on a slower PC and it's pretty bad. I'll mess around with it some more later, thanks for the feedback :)


[QUOTE=vee41] Here is an old example that also does forest generation. Play around with the variables for some funky results :)[/QUOTE]

I'll check out that Capx when I'm on my computer, thanks!Exuro2013-08-16 17:50:54
B
10
S
2
G
2
Posts: 12
Reputation: 1,709


Return to How do I....?

Who is online

Users browsing this forum: DharmaOne and 6 guests