#### Archived

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

# Bodies of Water

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

## 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 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 on other sites
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 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 on other sites
If you''re using a 3D API for rendering, you can also use a water plane - the Z buffer will take care of making it the correct shape.

- JQ
Full Speed Games. Coming soon.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633705
• Total Posts
3013463
×