1
\$\begingroup\$

I have read numerous articles on the subject but can find none that can explain to me how it is that procedural river generation achieves a certain amount of thickness to the river. I have managed to pice together that I must search for perpendicular vectors to the one I use to construct the river, but am not sure how that is implemented. I am working on a 2D game with tilemaps implemented and don't know how I iterate through the tiles to achieve the intended result.

I am fairly intermediate when it comes to game development and have just started proc-gen games. Please try to answer simply as to how to do this. I know that others have figured it out and want an answer.

How do I set the thickness of procedurally generated rivers?

EDIT

I am able to code simple straight lines and have access to an astar algorithm to connect two points together, but my river is literally one tile thick. I want to increase its size and I am not proficient in other programming languages enough yet to be able to read through source code.

The rivers I want just need thickness to them. I just need whatever technique others might use to produce rivers or roads thicker than a single tile.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Everyone who implements procedural generation tends to do it slightly differently, depending on their game's visual style and the kind of output they want. Can you edit your question to add some visual examples of what "good rivers" for your game would look like, or what kinds of bad generator output we should try to avoid? \$\endgroup\$
    – DMGregory
    Nov 22 '20 at 12:18
  • \$\begingroup\$ When I coded proc gen rivers, I found that river width & depth needed to be tied to my game play goals related to how easy or difficult crossing should be for a map location. For example: how strongly did I want to force a ground movement bottle neck on a bridge? In addition to some good & bad examples, consider including some info regarding what makes a river well / poorly generated for your gameplay. \$\endgroup\$
    – Pikalek
    Nov 22 '20 at 16:06
2
\$\begingroup\$

If your only requirement is plotting out a thicker line of river tiles along a path of points, you can simply do the following:

To get a river of width w then for each (x,y) position along the path:

for(Point p : path){
   for(int a=0; a<w; a++){
      for(int b=0; b<w; b++){
         mapTile[p.x+a][p.y+b] = river;
      }
   }
}

This is a brute force approach in that it will blindly set the same tiles to the same value multiple. In my situation I only used it during initialization & found that it executed fast enough that it wasn't worth optimizing.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.