Search code examples
java2dprocedural-generationperlin-noisesimplex-noise

2D Platformer procedural world generator


i am currently developing a 2D tile based java platformer. Not to earn money, just for fun. Recently i found this game called Caveblazers. It is a 2D platformer too and i think it is also tile based. It's world is procedurally generated and looks different everytime you play the game. I tried to experiment with perlin noise and simplex noise, but it didn't work out as planned. I couldn't even make sure, that the level is possible and there are no walls obstructing the goal. My game is going to be a lan based game, also in caves. So my question is how to generating these awesome looking caves and how to get locations to place scaffoldings and chests. Help would be very appreciated and since it has to be playable until next week, i would love to get a quick answer!

That is how i would like it to be:


Solution

  • Think of perlin noise as smooth more or less boring terrain heightmap.

    Values generally range from 0 to 1, or -1 to 1.

    First test your perlin noise code in a separate application / UI, just with colors or 3 tiles, once you master this try mapping to better tiles.

    https://www.redblobgames.com/maps/terrain-from-noise/

    The mapping is up to you, but in general what would be hills in the heightmap are walls in your 2d platformer and deeper points are left empty/transparent or filled with background tiles.

    In addition to this you will want to ensure passage maybe using some bot which checks that the caves are passable, the bot may carve some extra smoothed passages using additional code. You cannot achieve this with pure perlin noise so this second step is more art than science. In general the code carves tunnels into the perlin noise by averaging values to avoid rude edges.

    May be use something like random walk + some direction, see: https://gist.github.com/jeffThompson/5608847