2d World Generation

Started by
7 comments, last by M6dEEp 12 years, 4 months ago
Hi,
I am trying to implement 2d world generation similar to that of minecraft and Terraria.
There should be grass, trees, dirt, caves etc. I am using C/C++ and OpenGL

I am not sure how to approach this problem with reusable/efficient code that can be integrable with other game
engines for future use.

Does it need to be done using some random number generator or using perlin noise algorithm. I am not sure
whether Noise algorithm will be suitable for 2d side scroller type of game with lot of different sprites to be generated.


All suggestions are welcome.
Advertisement

Hi,
I am trying to implement 2d world generation similar to that of minecraft and Terraria.
There should be grass, trees, dirt, caves etc. I am using C/C++ and OpenGL

I am not sure how to approach this problem with reusable/efficient code that can be integrable with other game
engines for future use.

Does it need to be done using some random number generator or using perlin noise algorithm. I am not sure
whether Noise algorithm will be suitable for 2d side scroller type of game with lot of different sprites to be generated.


All suggestions are welcome.


I made a simple algorithm in java once, to generate a terrain. first you have to know some facts. how plausible it is that a grass is near a dirt block and so on. then you have a random starting point. its really simple:
1. compute random starting point
2. iteration for every y-axis:
2.1 calculate new x point depending on last x point
2.2 now you have to fill the terrain under the random x point. here come your different materials. so there are some "rules" that you should etablish yourself. example:
-every block on the top of the terrain is a grass block
-the second one is a dirt block and it becomse more probable that there is stone, the deeper you go.

i hope i helped you and sorry if you dont unterstand my not so good writing skills. feel free to ask me ;)

You will certainly want a good noise algorithm even for a tile based world. A RNG will only give you a mess where noise combined to give turbulence will give good effects.
Hi,
Any idea how terraria

has gone about generating world maps?

Is it done using noise algorithms for side scrolling type of game?
Yeah that's just a form of noise. I tend to just use value noise. Here is a simple value noise example:
http://sirisian.com/javascriptgame/tests/valuenoise2.html
Right click to view source. Noise is mostly just magic numbers. Perlin and simplex noise are other noise functions. Focus on creating each feature you want independently like lakes, rivers, mountains then merge them together.

Yeah that's just a form of noise. I tend to just use value noise. Here is a simple value noise example:
http://sirisian.com/...aluenoise2.html
Right click to view source. Noise is mostly just magic numbers. Perlin and simplex noise are other noise functions. Focus on creating each feature you want independently like lakes, rivers, mountains then merge them together.


Thanks. But is there any visual in that webpage, as I am not able to see anything, I can see the source.

Thanks. But is there any visual in that webpage, as I am not able to see anything, I can see the source.

Firefox or Chrome probably. It uses the canvas tag so HTML 5 only.
HI,
Thanks for the replies.
I want to know from where should I start coding about 2d procedural generation in order to understand it in a step by step manner.

Any recommended tutorials are there please do suggest it.
I'm currently working on my own rendition of Minecraft right now and have worked on other procedural stuff purely because I didn't have access to artwork and found it easier to code in models than make them by hand :P. In my experience working on procedural generation stuff is pretty much going to be your own adventure because there isn't a *whole lot* of stuff out there specifically pertaining to what you're trying to do. Your best bet is doing what the other guys said and read up on noise algorithms and experiment with different techniques.

As far as 2d tile worlds like Terraria go I don't believe it would be any different from generating a top down RPG game world randomly. From my current project, the 3d block world I found it extremely easy to work with smaller pieces with scalability in mind. I started by generating 4x4 chunks with 1 block a piece and worked on the face culling. Then I scaled it up and looked for any errors and fixed my algorithms and continued. After I made sure everything worked out ok, then I started applying Perlin noises etc to see what I liked.

All in all, procedural generation is really fun to do but requires a lot of experimentation and time to implement. You'll find yourself reading more about theory, analysis and technical details than actual step by step tutorials. That's just my experience thus far though and don't get discouraged.

PS here is a great site that I forgot to mention, it's a one stop shop for procedural generation topics:
http://pcg.wikidot.com/

This topic is closed to new replies.

Advertisement