Archived

This topic is now archived and is closed to further replies.

Generating random 2D landscape ???

This topic is 6483 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi !!! I''m programming a tankwars clone and i have problems with the random landscape. It doesn''t look round. I wanted to how I could make it look round and smooth ??? THX !!! _______ mtfbwy

Share on other sites
Apply your randomly generated height coordinates to the amplitude of the sine function (height * sin(y))

Share on other sites
i dont get what your getting at (whirly)wouldnt that just make your land the shape of a sine wave ie. not random.

Share on other sites
For my Lunar lander game, I took the value of the last height and added a random number.

height[x] = height[x-1] + rand()%16 - 8;

that way it won''t look very spiky but it won''t be all that smooth.

What you could do is generate a few random points across the map and draw lines/arcs connecting the points. Then fill in the bottom.

Share on other sites
do a search for beizer patches, they sound like the right way to go for your situation.

Share on other sites
Oh, height is a random variable. It will look like a randomly modulated sine wave, depending on the frequency (determined by ''y''). The beizer patch is a simular approach, just using a different function (quadradic equation - aX^n+ .. + xX^2 + yX + z, where n can be any number - if my memory serves me right).

Share on other sites
using a sin wave will produce generally similar patterns each time - you could offset the wave initially or use random amplitude, but the basic shape would be the same each time. whereas a beizer can be given any amount of random control points to produce a more varied output.

the only downfall of the bezier method is that it is more difficult to implement (but that should be an incentive!)

Edited by - Yorvik on February 12, 2001 8:38:48 PM

Share on other sites
Thank you for your help !!
I finally got a round and smooth landscape, i used the sin function.
If anybody is interested:
I added 4 sin function with random amplitudes and moved them randomly in x-direction. Then I divided it by 4 again.
Now it looks round and smooth !!!!

Freak

_______
mtfbwy

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• Forum Statistics

• Total Topics
633295
• Total Posts
3011245
• Who's Online (See full list)

There are no registered users currently online

×