Page 1 of 1

How do I Create procedural Water

PostPosted: Sat Nov 07, 2015 7:41 pm
by cmota123
Hello, my name is Carlos I have a procedurally generated world and when it bitwise completes I would like to fill some areas with water but I can't seem to be able to do this I would really appreciate the help of anyone who is willing to help and Thank you. I just need help in Tilemap Water that flows and stops at solids.

Re: How do I Create procedural Water

PostPosted: Sun Nov 08, 2015 12:52 am
by bleddyuffles
For the purpose of this example I'm going to assume your world is built up of blocks, like terraria. Im sure you could adapt this if it isn't, but anyways.

What I would do is something along the lines of, When a "block" of water is created, spawn "check" blocks to the down, left, and right of it. If these check blocks collide with a solid block, say "stone", then delete the check block, and do nothing else. This way, your "check" block spawns to the right of the water source, checks if theres a solid wall to the right of it, if there is, then no water flows to that block. If there isn't, however, a block at this spot, delete the check block and replace it with a water block.

It wouldn't be this simple, you'd have to have it check if theres a solid underneath it, otherwise it would flow off for infinity at the same height, stuff like that, but hopefully you get the general idea of what I mean. I'm sure theres a much easier way of doing this with arrays, but I personally like to avoid arrays.

Re: How do I Create procedural Water

PostPosted: Sun Nov 08, 2015 1:40 am
by cmota123
I'm using Tilemaps is there a way to check it with those.

Re: How do I Create procedural Water

PostPosted: Sun Nov 08, 2015 2:12 am
by R0J0hound
You could use two for loops to check each tile in the tilemap. Then just check the tiles around it if it's a water tile.

There's an old example of grid based water here:
what-is-the-attributes-counterpart-in-construct-2_p715663?#p715663

Re: How do I Create procedural Water

PostPosted: Sun Nov 08, 2015 2:22 am
by cmota123
Thanks, R0J0hound I will try it

Re: How do I Create procedural Water

PostPosted: Sun Nov 08, 2015 2:38 am
by cmota123
I got it to work on tilemap, thank you guys for your help really it awesome.