Random World Generation

Get help using Construct 2

Post » Sun Jun 02, 2013 10:00 pm

Hi Guys! So, I have my game generate a world by randomly placing trees, and things. But one thing I want to prevent is Trees overlapping weirdly. Like this:

To prevent this, I have this:
The problem is, this doesn't seem to work! And every time I use the "While" loop, the game freezes, and refuses to work. What I want to know is, is there any way to fix this? Does anybody know a better way to randomly generate a world? I can't use an array, because it isn't a tile map. I would really appreciate it of someone could help me out. Thanks!InvaderX2013-06-02 22:02:51
B
30
S
8
G
3
Posts: 366
Reputation: 6,302

Post » Sun Jun 02, 2013 10:08 pm

An easy way is just place them randomly, then do an overlap check and if overlapping destroy top instance

another way would be have two global variables plot them out and add to the variables in a loop...
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Sun Jun 02, 2013 11:03 pm

Its not necessary all this burocratic stuff.

The simplest Solution: ZOrder.capx

This works well with Moving Objects to. Just insert in the family and works well.
B
13
S
3
G
1
Posts: 60
Reputation: 1,828

Post » Sun Jun 02, 2013 11:13 pm

The solution for Forest Generation.

ForestGeneration.capx

Works well with other Objects too if you want. Like Rocks,flowers,enemies.

Obs:. It orders at the end the Z order.

Dictionary:
   Variables:
       Density = Lower the density value, more dense its the forest.
       RootPoints = The amount of Root points.
The OverlapAllowed variable its kinda a boolean that will permit or not to have trees overlapping anothers.

Make your tests and implement it as well.

psycholize2013-06-02 23:14:07
B
13
S
3
G
1
Posts: 60
Reputation: 1,828

Post » Sun Jun 02, 2013 11:21 pm

To speed up the Forest Generation simpy replicate many times you want the 3 event. More replicated = Faster Generation.

1 Event = 250 Trees in 4 Seconds.
20 Events = 250 Trees in 0.4 Seconds.psycholize2013-06-02 23:27:02
B
13
S
3
G
1
Posts: 60
Reputation: 1,828

Post » Sun Jun 02, 2013 11:30 pm

@psycholize Ooooh! Your CAPX it really cool! The only problem is in my game, it seems to get really laggy when the tree count goes over 500?
B
30
S
8
G
3
Posts: 366
Reputation: 6,302

Post » Sun Jun 02, 2013 11:49 pm

Ohh!

Usually when my is Laggy I start all over again.
Try to Adapt the one I've shared.
You dont have to rewrite all your project. Just this solution.
B
13
S
3
G
1
Posts: 60
Reputation: 1,828

Post » Sun Jun 02, 2013 11:57 pm

@psycholize Its seems to work well in my game, Thanks!
B
30
S
8
G
3
Posts: 366
Reputation: 6,302

Post » Fri Jun 28, 2013 8:09 pm

Hey, I checked out that random generation psycholize posted and I got it to generate 250 trees in a second with just 4 events.

preview:https: //dl.dropboxusercontent.com/u/175478835/Tutorials/Forest%20generation/index.html

download: https://dl.dropboxusercontent.com/u/175478835/Tutorials/ForestGeneration.capx
B
8
S
2
Posts: 15
Reputation: 630


Return to How do I....?

Who is online

Users browsing this forum: datiel12, Google [Bot], tarek2 and 67 guests