Question

I am making a 2d platformer, and am trying to get some auto-terrain generation. I have found a Perlin noise function, however it isn't really helping, it is generated noise, but there are some platforms high in the air, and sometimes the perlin noise will output something good, but most of the time it isn't that "playable". How can I make simple terrain generation for a 2d platformer, in Java? A point in the right direction would be perfect.

Was it helpful?

Solution

The role of terrain generators, generally, is to create something that looks natural, rather than hand-crafted, so if you want your terrain to look a certain way you'll need to create a list of "valid" or "desirable" attributes that you can define in such a way that you can compare the generated terrain against those list of attributes, only accepting randomly generated terrain that meets those attributes. This will give you a balance of natural, and well-crafted, terrain similar to games like Diablo II, where the landscape is random (per player), but flows well.

So, it really depends on your game. Attributes that you might think of generally are things like:

  • density
  • maximum height between generated platforms
  • checks for obstacles that be scaled/are too tall, or shaped in such a way (based on the player's movement limitations) that they are otherwise impassable
  • "cave" detection where a player is spawned inside of a cave, with walls on all side, and can't get out
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top