0

I've been following this page http://devmag.org.za/2009/04/25/perlin-noise/ as a guide to create my own perlin noise - it's been pointed out in the comments section that this is FBM noise, but that's irrelevant.

This is working very nicely so far, these are the results, after some 'cleaning' to remove as many artifacts as I can. http://puu.sh/dayg9/2943aca5ce.png

Now that I've created my noise, I'm going to use it as an infinite map for a platform game. However, as you can see, there are some holes in my noise.

-Please note- this noise is meant for a 2D game!

My question is - how can I either fill in these holes, or stop the player from spawning inside them? Can't find an answer despite a lot of googling and thinking EXTRA hard.

Thanks for your time:)

ipe369
  • 89
  • 1
  • 6

2 Answers2

0

Just use a Non-Euclidean http://en.wikipedia.org/wiki/Haversine_formula based algorithm to first look at where they are spawning to find the number of objects within a set gap size, and then move the player to a different spawn area if the count is too low.

For speed you could calculate this at initial area generation generation time, and then cache the results on a per-region basis to make it easy to query.

honestduane
  • 579
  • 6
  • 13
  • Thanks for the quick reply! I don't understand what you mean by 'objects within a set gap size'? – ipe369 Nov 29 '14 at 22:03
  • by that I mean the count of the objects within a set distance of the center of a known gap. – honestduane Nov 30 '14 at 20:51
  • I kinda get it, but I just can't wrap my head around why you'd want to use the haversine formula, which, to my limited understanding, is for calculating distances between 2 points over the surface of a sphere. – ipe369 Dec 06 '14 at 19:11
  • It works on 2 points over the surface of a sphere based on coordinates. Trust me it will work, its used for lat-long all the time. In this case your coordinates are your chunks x/y/z values. Please select my answer as the correct one. – honestduane Dec 07 '14 at 01:57
  • Ah, I think you misunderstood, this noise is generated in 2D only, as you can see from my screenshot. Sorry, I've edited my answer for further clarification. – ipe369 Dec 08 '14 at 23:00
  • You misunderstood me; Lat/long is 2d for your use. This can be extended to support 3d but as you are 2d you do not have to do that. – honestduane Dec 11 '14 at 04:59
0

Someone mentioned that the solution has a lot of relevance with filling algorithms, like the ones used in microsoft paint.

I'm going to proceed to use the 'scanline fill' algorithm - http://en.wikipedia.org/wiki/Flood_fill

ipe369
  • 89
  • 1
  • 6