Archived

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

Bodies of Water

This topic is 5582 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 everyone, glad to report that my 2d engine is doing very well with collision detection, props, and that kinda thing. One thing I was wondering about is placing random bodies of water, without them seeming too blocky or broken up (water tile here, over there, oh look there''s 2 down here). My maps are stored in a one dimensional array TILES[maparea]. Generally my maps total area has not exceeded 900 sq. tiles. With that in mind, how would I create a dynamic river / lake function? A river that travels right to left or up and down would be easy enough, but I want stuff with curves, forks, etc.

Share this post


Link to post
Share on other sites
For either of those, fractal algorithms (preferably nonrecursive) are your best friends.

For an example river. Make a single line that goes from a random spot on the east edge to somewhere on the western. Apply the fractal algorithm to split it into lots of lines. Now, to generate the river itself... set a "RiverWidth" variable. For each whose center is within RiverWidth tiles of a line, make it into water.

Once all tiles/lines are processed, apply your tile-edge transitions and/or such.

And remember, that''s only one way to do it!

Suggestion for lakes; make an oval, randomly rotate it, apply the fractalization algorithm to it, add a river going from the north map edge to the center of the lake, add a river going from just to the east of lake center to the southeastern edge of the map. And so on. And tweak your maps after generating the fractal rivers/lakes, if you can...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If your maps have height information, you can also try and
follow the slope (eg the most likely place for a river to go
is the lowest square around).

Share this post


Link to post
Share on other sites
The most important part is the transition tiles - the ones that have the shore of the body of water. If you design these right, you shouldn''t have any problem really with a blocky look. All you really need are the 4 straight edges and the 4 diaganol edges, although a few extras to add some variance wouldn''t hurt.

Share this post


Link to post
Share on other sites