Posted by: Art Comben on Sun 5th Jul 2009 at 7:02pm
Tags: ActionScript, Labs
The algorithm I used for this is charmingly simple and works a little like this.
You create two two-dimensional arrays representing a grid. Every frame you iterate through one of them.
Each item in the arrays contains a number representing for instance, the height of the wave.
For each point in the grid for the top array you take the sum of the values of the point above, below, to the left and to the right from the bottom array, divide this number by two and subtract the value of the current point in the top array. This becomes the new value of the current point.
Now just swap the arrays so the top one becomes the bottom one.
The beauty of this is that you can create as much turbulence as you like and it still affects the processor in the same way.
Art that is really cool, altho it does play with your eyes after a while lol
Glad you like it Raj, we’re going to add the source code when we’ve got a spare moment to add code highlighting to the blog.
Really great effect, I can see it being pretty flexible - unfortunately I don’t speak AS quite as fluently as you do Art but I’d love to see the code behind it!
That is really quite cool! Nice work Art.