While working on an idea for the mini ludum ‘blood in the water’ I made a prototype that was unusable but still had a nice visual effect.
In this prototype I create some random currents in the water and particles follow the current. The green triangle can be steered with the arrow keys (but you can also stay put to see where the stream of particles will go). Before you can steer you click on it to get the focus.
It’s made in Flash and I’m not sure how older computers cope (you can end up with about 10.000 particles).
The way it works: I create a grid of cells where each cell has a direction. At first I tried to give every cell in the grid a direction based on the surrounding fields, but it got too complicated, so now every cell has a random direction. A particle will have its speed modified based on the direction of the cell it occupies and the cells directly surrounding it (but the influence of the surrounding cells is lessened by the distance to the particle). Surprisingly it looks very much like a real current.