Generating random 2D landscape ???
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
_______mtfbwy
Apply your randomly generated height coordinates to the amplitude of the sine function (height * sin(y))
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.
please explain.
yeah boy
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.
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.
do a search for beizer patches, they sound like the right way to go for your situation.
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).
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
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
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
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
_______mtfbwy
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement