![]() |
| [[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]] |
|
|
#1 |
|
Valued Member
Join Date: Sep 2004
Posts: 115
|
For my first submission to the Code Spotlight, I have this little 2D terrain generation algorithm that I'm quite proud of. It requires you to have defined an std::list<float> called 'terrain' somewhere in your code, probably a global would be best (an updated version which takes the correct terrain list as a parameter is in the works).
The iterations parameter for MakeTerrain() simply controls how many times it loops over, adding more points as it goes, and the roughness parameter sort of controls how much the random range is reduced each time through the loop (basically, the higher the value, the less big spikes you will see in your terrain). Don't expect anything pretty when you run this - all this algorithm does is produce the raw data, it's up to you to do something with it. My own testbed program which I used to give me something to build on only displays the results as a list of numbers, but it's enough to show that it works! Here's the code: Code:
|
|
|
|
|
|
#2 |
|
New Member
Join Date: Jul 2005
Posts: 1
|
you are so brilliant - keep up the good work!
![]() |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|