Random World Generation

0 favourites
  • 9 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • 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:

    <img src="https://dl.dropboxusercontent.com/u/61808535/TreeOver.png" border="0" />

    To prevent this, I have this: <img src="https://dl.dropboxusercontent.com/u/61808535/TreeGenEvents.png" border="0" />

    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!

  • Try Construct 3

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

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

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

    <img src="smileys/smiley1.gif" border="0" align="middle">

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

    <img src="smileys/smiley2.gif" border="0" align="middle">

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

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

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

  • psycholize Its seems to work well in my game, Thanks!

  • 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: dl.dropboxusercontent.com/u/175478835/Tutorials/ForestGeneration.capx

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