Jump to content
  • Advertisement

Archived

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

Freak

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.

If you intended to correct an error in the post then please contact us.

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 this post


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

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!