Made a sand simulator
i made this cool sand falling simulator.
i made this cool sand falling simulator.
im proud of the rendering algorithm.
first time i actually got recursion to work and make it faster!
normally give up at "max call stack exceeded" :/.
thank you chat gpt!
DEMO
Play the game here!
Dev progress
i saw a developer talk about making a sand falling game.
and realized its just a super cellular automata like simulation! which was super exciting because i just reciently did something similar
I saw the coding description and said i got to make me one of those!
My progress over time
mine: got sand falling on the first try*!
(* ) minus some bugs
then got the sand piling beahvor setup
tried scaling it up but it was WAY TOO SO.
Here where recursion comes in.
How the algorithm works
create a square test to see if it has any pixels in it.
remove ones with no pixels
keep sub dividing
until you have sufficient accuracy.
for me it ended up be maxing out at 20 sub divisions
Speed
improved the speed from 1 second per draw to 16ms!
thats more like it!
twittling with settings
Quadtree
I think its similar to this thing called a quad tree
Just found out what its called when making this writeup. COOL!
i think they have some cool effiancy things
like storing the quadrents as left right nodes of a tree like this. very cool
example from Wikipedia
More things you might like!
ant simulator
Thanks for reading!
Author
by oran collins
github.com/wisehackermonkey