LibGDX Procedural Generation

Ahoy!

I have recently been fascinated with randomized generation, although I am a bit stumped on coming up with a method of generating platformer style 2D generation, such as terraria or starbound. The method I am working around is this: http://www.java-gaming.org/topics/libgdx-2d-top-down-procedurally-generated-terrain/30281/view.html

Any suggestions or pointers on leading me into a good direction?

Thanks!

procedure generation techniques tend to be based on some sort of math procedure that is run to “generate” a result that is then interpreted as your landscape…

A common one is called perlin noise. When you run this you get something that resembles TV static.
But if you run it three times at say different resolutions… and then merge them together you get an image that resembles the natural transition between hilly and flat land areas.

(this of the first run as the pebbles… the next is the hills and the last as the mountains… mix them together and you get a more natural looking result)

Im not entirely sure how you would want to take this into a 2d game… but im sure there are techniques (or others may chime in with what they have done + ideas)

cheers.
j.

Okay, now that I’ve had time to actually practice with random generation (top down) and culling, I have come to find that I actually need someone to help with the entire subject.
I have been reading this post: http://www.java-gaming.org/topics/libgdx-2d-top-down-procedurally-generated-terrain/30281/view.html

I am quite confused to be honest. I understand the general idea of using a noise height map… but without the entire code its a bit… hard. Also, culling. How do you find the bottom and top coordinates (x0, y0, x1, y1) for the camera viewport?

I have no idea what I am doing. What I am trying to achieve: For example, a basic, yet random, island with grass and sand in the middle of an ocean. The island is bigger than the original screen view port, yet isn’t rendered if not on camera.

Also, how would saving a map work and not generating a new one unless told to?

Thanks!

  • A

K… in reading the responses it seems you have multiple questions.

ill try to answer all the ones i made note of:

  1. how do you save your map… vs generating a new one.
    After you generate your map you may want to store the result in a file or database of some sort. This is the most straight forward answer.
    As for regenerating… its important to know that most noise approaches involve using a seed value (a random number). If you use the same seed value again the result of the noise algorythm should be the same every single time.

  2. how to get the width / height
    It sounded like you were asking about how to setup the view / camera matrix for rendering the screen. If so then the link provided is a start (in previous post) keep in mind just cause you used a map to generate your terran doesnt really change how you would draw or render your 3d scene.

  3. from map to game.
    ok you made your noise map… now what? its really up to you to decide what the dark vs light elements of map mean and translate that to a map you can display. Perhaps the map is 1000x times bigger than what you want to show on screen at one time… thats up to you. :slight_smile: the trick is procedurally decide how to interpret the values and build your “real” game map based on them.