Real time terrain generation

Looking at wonderful games like:

…my common sense is whispering at me that we could do these kind of lazy roads with meshes in stead of pixel layers…I’m not that smart to figure out a cool formula which distributes the entire shape of a level, then modify a poisson value of the terrain machine and get the next level in just a millisecond…
some kind of help would be appreciated, i think i getting in so much recursion :smiley:

easiest way is to use random seeds.the first time the app is run it generates 50 random levels and saves them as local data. then, after all of them have been used, it generates another fifty. the user might notice it occasionally takes five times longer than normal to load, but since it woud never happen twice in a row they woudnt care enough tio remember.

That was fast @KMEB ,with the level data-part in mind, let’s talk about information generation, would it be better to generate terrain 3 dimensional vectors or just height levels separated by a distance (x,y → two dimensional vectors)…?
i think it depends on which choice are you going to take in order to make all the drawing and game logic, paths, etc.

It all depends on what kind of game you are making. Are you talking about a 3d or 2d platformer?an rpg? A “1d” platformer: such as tiny wings or doodle jump in which you only modify one variable?

If its any of them but the last, the best way to go is modified Perrin noise with prefabs dropped in in key places.

However, games such as tiny wins are actually just modified sine waves- for example, this generates the height of a mountian in a tiny wings like mountian, given x-

H = asin(x-(2+sin(bsin(x-c)/10)))+d*sin(x/e)

And before generating set a- e to random values. I’d recommend the ranges of
A- 5,7
B- 1,2
C- -100,100
D- 10,15
E- 10,20

Pilot Winds (which I mostly wrote the game code for) just generates the next section using a random number generator.

It just decides where the next segment of the level should go once the camera has moved far enough to the right. The peaks are made by creating a random downward slope once either the last segment is too high, or with a random chance, then adding a small amount to the slope for each subsequent piece to create the upward curve.

Doing this with a few mesh objects shouldn’t be too hard, I was actually thinking about rewriting Pilot Winds in Codea at some point.

for @KMEB : I founded here a complete explanation:

you can see that Ray use snip and win-size to generate the maximun hill length that the player can see to render it non-stop.

hey, @Dylan : in the url from Ray the random function is :

for(int i = 0; i < kMaxHillKeyPoints; ++i) {
        _hillKeyPoints[i] = CGPointMake(x, y);
        x += winSize.width/2;
        y = random() % (int) winSize.height;

these values are generated each hill,where the peak set is made of strips for the current segment, …is your random method supporting more smooth and creativity?

@juaxix For readability here is a formatted version of your for loop:

for(int i = 0; i < kMaxHillKeyPoints; ++i) { 
	_hillKeyPoints[i] = CGPointMake(x, y); 
	x += winSize.width/2; y = random() % (int) winSize.height; 

thanks @JockM ,i have edited my previous comment :slight_smile:

This guy , @pepinganos has made it :slight_smile:

Hi guys,

I need help with generate 2d terrain. I made it as large array where each pixel represent 0 or 1. The result you can see on image. The problem is that I need make huge map and this metod is very slow. Could you help me with some better way how to code this? Thanks (