You’ve probably tried at least one of them. Perhaps this one written in Java. When I first started to learn Flash I had a small competition with Chris from Nonoba about who could write the fastest sand particle “simulator”. I write “simulator” because it has obviously got nothing to do with any real physics, but it’s still a fun experiment.
Chris ended up writing this sandbox toy while I went in a slightly different direction and wanted to create something more computationally intensive to simulate: Water.
Performance is obviously a huge issue in this kind of project as you really push the boundaries of how many pixels and operations Flash can pull through. If you want to know how I ended up approaching it, you will have to look through the code as it has been way too long. However, I do remember that it ended up being able to handle about 20% as many particles as Chris’ sand toy. 20% sounds like a low number, but it is actually quite fast considering the amount of checks that have to be made to make it seem water-like compared to sand-like. Whether it can be made with fewer operations is another question entirely 🙂
I originally had plans for making this toy into a game of sorts but although the effect is pretty cool, solid game ideas based on it were really hard to come by. I remember one game where you had to rescue lemming like creatures by pouring down sand to let them climb to the finish. It was nicely implemented, but stunningly boring as it was extremely slow and really just Lemmings with a twist that made the game worse than the original.
The best idea I came up with was to have a cavernous world filled with rock and water. Some rock you wouldn’t be able to carve through and other rock would be more soft. There would be a raft with people in it that would have to sail through the caves without hitting the bottom or the ceiling – so it would be up to you, the player, to either pour down water to raise the water level or remove the soft rock to lower it.
And for the competition with Chris. I did find a faster way than his, which he ended up using in his Sand Toy with a few other optimizations 🙂