Every now and then I like to code something just for the fun of seeing what I can create. Recently I’ve been working on a 3D water sim in flash. Check it out below. If you’re curious as to how the water in Minecraft or Dwarf Fortress works, this is for you.
[SWF]/wp-content/uploads/2010/10/FancyFluids.swf, 600, 400[/SWF]
The tech is inspired by that of Dwarf Fortress (which you can read about here), with a couple of my own additions. It is based on two core concepts. Firstly, water always falls down; if there is an empty cell below a cell of water, move that water down. Secondly, if a cell of water is connected to an empty cell somewhere below, teleport the water there.
One of my more interesting additions is that water ‘prefers’ to move consistently in one direction, as opposed to whichever direction is easiest. This means you can get jets of water that spurt out of high pressure areas. Take a look at demo 2 to see that in action.
If theres anything you would like to know in more detail, or if you have any suggestions leave a comment below!
You can download the source here, but be warned: it ain’t pretty.