Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 17 Nov 2012
Offline Last Active Oct 03 2013 04:01 AM

#5012988 Implementing Simplex Noise for 2D terrain generation

Posted by on 20 December 2012 - 05:28 PM

So I really don't like this class, and that's mostly because it is based on System.Random.
System.Random is a fine tool for random number generation, but it doesn't offer any of the advantages of perlin/simplex noise. In particular, it is not continuous, whereas perlin/simplex noise is continuous even in its first derivative. This has a huge effect on the quality of generated worlds, and will become very evident if you ever implement per-pixel lighting.
System.Random also comes with a number of other disadvantages. Chief among them is that it explicitly isn't guaranteed deterministic between .Net releases (or platforms) - there is a good chance that you will run your program on a different version of .Net, or a different machine, and you will get a completely different procedural world from the same seed value.
Given that the OP already has a working simplex noise generator (I too use an implementation derived from Gustavson's code), I'd strongly suggest he stick with it.

That's agreeable, it seems that his issues lie in the implementation/use of the noise generator.
I've tried generating a 1D heightmap for a base ground area, and it didn't look very good. What I recommend is that you generate a 2D noise map, then have a gradient influence it.

Here's what I used when I was making a similar game:

In basic pseudocode implementation terms, you want to generate an array as big as your 2D noise-generated map, but with a gradient, where the bottom-most row starts at 1.0, and interpolates to 0.0 at the top row. You then loop through each value on the gradient map, and multiply the value of the cell respective to the noise map. When generating the tiles in your world you simply want to read the final result's map and only create tiles on cells that have a height value above 0.5 or something around there. That's how I did mine, and here's a screencap of the result.


You can also increase or dampen the amount the gradient influences the noisemap for some really interesting terrain.



After generating a map a few times, swiftcoder's post is really proving to be true. I generated worlds about 20 times and they didn't vary very much, and sometimes they were nearly identical. Strange.

#5012720 Implementing Simplex Noise for 2D terrain generation

Posted by on 20 December 2012 - 12:03 AM

As much as I don't want to say "Just throw all that away and use this class", but just throw it all away and use this class.

I've used it tons of times. It's fast, extremely easy to implement, easy to understand, etc.
I can get a procedural world up and running in like five minutes in XNA this way.

Here's an example of the implementation.

#5012717 Interacting with signs. I need advice.

Posted by on 19 December 2012 - 11:50 PM

Having a character for each sign is a really bad idea. You should implement some sort of entity system so that you can add signs and other objects in the world separate from your tilemap. You gotta do it some time, right? Unless you don't plan on expanding your game past "The Adventures of Tinyguy: Rogue Sign-Reader Extreme".

I recommend looking through some general tile engine tutorials as well. Good luck, mang.

#5011941 C++ Engine Layout

Posted by on 18 December 2012 - 12:57 AM

Assuming I'm fully understanding your issue, the "extern" keyword should help you out.

After the Engine class declaration I just do
[source lang="cpp"]extern Engine engine;[/source]
Now you can reference the engine, and all of the modules it contains from anywhere. I had pretty much the same issue you had when making my first engine in C++. extern made my life way easier.