TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Sandspiel – A falling sand game built in Rust and WebGL

1323 pointsby 15DCFA8Fover 6 years ago

66 comments

chimeover 6 years ago
Wow! This thread brings back some fond memories. Long ago, I came across a tiny Java applet linked on Fark to a Japanese forum post. Everyone loved it but I found it annoyingly small. It was barely 300px x 400px. I had been coding my senior thesis in Java and had recently learned how to use a Java decompiler.<p>So I downloaded the applet, decompiled it, spent a few minutes figuring out exactly where the dimensions were setup, changed them to 960x640, compiled it all, and hosted it on my site: <a href="http:&#x2F;&#x2F;chir.ag&#x2F;stuff&#x2F;sand&#x2F;" rel="nofollow">http:&#x2F;&#x2F;chir.ag&#x2F;stuff&#x2F;sand&#x2F;</a><p>I&#x27;m always apprehensive about taking any credit for the Falling Sand Game because I DID NOT make it but I&#x27;m always glad to see it in the wild. First it was Fark, then a few months later Digg, then Reddit. At one point someone created a Wikipedia page linking to the enlarged version I was hosting, then it got deleted as not-notable, then someone wrote a song about FSG, then a hundred different versions of FSG popped up, many non-Java and functioning much better than the applet, then the Wikipedia page came back up.<p>I&#x27;ve long stopped getting giddy emails from office slackers about how much time they waste on my site but even though I didn&#x27;t really create this amazing game&#x2F;toy&#x2F;zen-garden, I feel lucky to have been a tiny part of the arcane pop-culture movement.
评论 #18697159 未加载
评论 #18705684 未加载
评论 #18700756 未加载
评论 #18697671 未加载
评论 #18699323 未加载
评论 #18758302 未加载
评论 #18697944 未加载
dTalover 6 years ago
A nice bit of web programming. The smoke effects look cool. Pity solids don&#x27;t conduct heat - the first thing I always try and do in these is boil a pot of water.<p>If you&#x27;ve never seen this kind of thing before, the canonical PC example is The Powder Toy, which is so amazing I wish there a 3D Minecraft-like version. But it&#x27;s really CPU-heavy even in 2d.
评论 #18698527 未加载
评论 #18698209 未加载
评论 #18702036 未加载
评论 #18696859 未加载
评论 #18696897 未加载
评论 #18698559 未加载
ullarahover 6 years ago
This is great, I love falling sand games.<p>The only downfall is that the Pythagorean Cup didn&#x27;t work?<p><a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;ejqBwR4.png" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;ejqBwR4.png</a><p><a href="https:&#x2F;&#x2F;sandspiel.club&#x2F;#cCZB5Un0exri2UajMjcu" rel="nofollow">https:&#x2F;&#x2F;sandspiel.club&#x2F;#cCZB5Un0exri2UajMjcu</a>
评论 #18697322 未加载
phaedrusover 6 years ago
Several years ago I wrote a falling sand game for the Parallax Propeller chip, which is an 8-core microcontroller. One core was needed to drive the video output, and I had up to 7 other cores running a simple ruleset:<p>1. If a sand pixel had an empty pixel below it, exchange them. 2. If more than two sand pixels are stacked but there&#x27;s space to the side, kick one sand grain out to that side.<p>These rules were enough to make the sand form simple hill shapes. All of the cores bash on the same shared memory array; rather than use locks or synchronization I just had each core start in a different column of the screen and all move left to right by columns - in theory there should be enough separation that they&#x27;d never conflict.<p>However - and this is the part I thought interesting to post about - somehow after a few seconds or minutes the 7 cores would catch up with each other and start running in lockstep (effectively reducing the speed of the simulation to equivalent of 1 core).<p>Barring a bug that was simply crashing cores, what I think was happening was that not every control flow path took the same number of cycles, so a core processing a column with a complex sand pattern might slow down and allow another core to catch up to it. Once two cores were operating on exactly the same data, they&#x27;d be doing the same deterministic logic on the same inputs and writing out the same result, effectively just duplicating the work in lockstep.
NextHendrixover 6 years ago
I wasted hours on these types of games back in the flash era, people were constantly releasing new ones with more types of sand and various effects and combinations, its a shame that whole segment of internet history was deprecated along with flash, good times.
评论 #18698238 未加载
评论 #18696709 未加载
评论 #18696442 未加载
tapirlover 6 years ago
What&#x27;s the performance difference from a pure JavaScript version?<p>Recently, I made a particle game which originally planned to be implemented with WASM. However, I decided to implement it with pure JS firstly. The result is some surprising that the JS version runs so smoothly that I think a WASM version is not essential any more.
评论 #18698161 未加载
GolDDranksover 6 years ago
This brings to mind a game that many people here might enjoy once it gets released – Noita: a magical action roguelite where every pixel is physically simulated.<p><a href="https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;881100&#x2F;Noita&#x2F;" rel="nofollow">https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;881100&#x2F;Noita&#x2F;</a><p>(Disclosure: it&#x27;s being developed by a bunch of my old co-workers.)
评论 #18698592 未加载
jasonkesterover 6 years ago
Fun feature: on mobile, if you drop a bunch of lava on a bunch of fireworks, your phone gets hot.<p>Nice work.
napsterbrover 6 years ago
Brings me back some good old memories from this game:<p><a href="https:&#x2F;&#x2F;dan-ball.jp&#x2F;en&#x2F;javagame&#x2F;dust&#x2F;" rel="nofollow">https:&#x2F;&#x2F;dan-ball.jp&#x2F;en&#x2F;javagame&#x2F;dust&#x2F;</a>
lhballover 6 years ago
Got tired of all the phalic-volcanoes so I made something nice for you <a href="https:&#x2F;&#x2F;sandspiel.club&#x2F;#2scDpZpyMACGp65FrkPT" rel="nofollow">https:&#x2F;&#x2F;sandspiel.club&#x2F;#2scDpZpyMACGp65FrkPT</a>
评论 #18696743 未加载
btschaeggover 6 years ago
This very strongly reminds me of a game called &quot;Hydroxis&quot; (or at least I think so) for the Amiga. You started with water pooling in some cavity in an otherwise static level and had to move it to a target location by means of enabling and disabling some blocking segments in the level. That was fun!<p>I had remembered that one a decade or so ago and it turned out to be the single hardest thing I tried to find for my WinUAE collection :-(
评论 #18697718 未加载
ummonkover 6 years ago
Grow some plants. Light a fire. Frantically try to put it out with water and watch helplessly as the plants grow due to water, providing more and more fuel for the growing flames, until you have an unstoppable conflagration on your hands. There must be some moral lesson to learn from this.
评论 #18699149 未加载
jetrinkover 6 years ago
Make a lake of oil, set it aflame and then pour water on it. A small amount of water causes the burning oil to flare and spread. A large amount of water extinguishes the fire. Very cool!
评论 #18697205 未加载
评论 #18696495 未加载
sorenjanover 6 years ago
I wish fire or lava would make steam out of water, but I love the smoke effect. It was a really nice surprise when the rest of it was so low resolution, great combo.
评论 #18696758 未加载
评论 #18698443 未加载
gamblerover 6 years ago
If you like this game, you might find this project interesting:<p><a href="http:&#x2F;&#x2F;tinlizzie.org&#x2F;~ohshima&#x2F;shadama2&#x2F;live2017&#x2F;" rel="nofollow">http:&#x2F;&#x2F;tinlizzie.org&#x2F;~ohshima&#x2F;shadama2&#x2F;live2017&#x2F;</a><p><a href="http:&#x2F;&#x2F;tinlizzie.org&#x2F;~ohshima&#x2F;shadama2&#x2F;" rel="nofollow">http:&#x2F;&#x2F;tinlizzie.org&#x2F;~ohshima&#x2F;shadama2&#x2F;</a><p>It&#x27;s a bit similar, but uses GPU and spawns millions of particles. On the other hand, it&#x27;s less of a sandbox and more of a demo. You can write your own code in the browser too, but it&#x27;s a bit tricky to program, because it compiles to shader language and it has some weird limitations.
t3hprogrammerover 6 years ago
This is awesome! A few years ago I built a more rudimentary version of a falling sand game with just Javascript and WebGL: <a href="http:&#x2F;&#x2F;ericleong.me&#x2F;sand.js&#x2F;" rel="nofollow">http:&#x2F;&#x2F;ericleong.me&#x2F;sand.js&#x2F;</a><p>I tried to embed the &quot;scripting&quot; language as a texture in WebGL to keep the implementation very fast (note that every pixel is a cell), but I think I worked myself into a corner.<p>Source code here: <a href="https:&#x2F;&#x2F;github.com&#x2F;ericleong&#x2F;sand.js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ericleong&#x2F;sand.js</a>
jacobdpover 6 years ago
Any source code for this? I&#x27;m learning rust right now and it would be really cool to see how this was made
评论 #18696657 未加载
评论 #18697327 未加载
评论 #18696652 未加载
spdustinover 6 years ago
Once I realized that pausing the FSG was a thing...<p><a href="https:&#x2F;&#x2F;sandspiel.club&#x2F;#Mt35KuNUFTZW9ITyWDxe" rel="nofollow">https:&#x2F;&#x2F;sandspiel.club&#x2F;#Mt35KuNUFTZW9ITyWDxe</a>
tokyodudeover 6 years ago
This is a perfect example of why I&#x27;m still in Chrome. At least for me this runs at 60fps in Chrome on my Mac but 30-45 in Firefox. I see this often in animated sites.
评论 #18696827 未加载
评论 #18697733 未加载
city41over 6 years ago
Thousands of particles and the worst frame rate I saw on my iPhone 6 was 25fps. Impressive.
louskenover 6 years ago
Not seeing vaporizing water when lava was put into it was a bit of a bummer, otherwise it&#x27;s great
Ezkuover 6 years ago
Love the performance, no trouble with 60fps. The swirly wind, fire, and smoke effects are beautiful! It’s also the only part here with which I would not know how to get started building, could anyone share their thoughts on the implementation?
评论 #18697334 未加载
flaqueover 6 years ago
This feels wayyy smoother than I remember this game being.
评论 #18696522 未加载
nagyadam2092over 6 years ago
A question to the creator: is the fungus growing respecting the rules of Conway&#x27;s Game of Life? It seems very much like that. Very nice app!
mlindnerover 6 years ago
My current map set up, paused. <a href="https:&#x2F;&#x2F;imgur.com&#x2F;71p1H8W" rel="nofollow">https:&#x2F;&#x2F;imgur.com&#x2F;71p1H8W</a>
评论 #18698653 未加载
devilmoonover 6 years ago
Holy shit, I remember playing something very similar to this for hours on end in the early 90s as a kid; it might have even been an early version of the powder toy (another user mentioned it), not entirely sure, but regardless this thread is making me go back down memory lane and now I&#x27;d love to get into the insides of a game like this one and understand how it works!
评论 #18697721 未加载
Tade0over 6 years ago
You can get some interesting effects if you put a grid of one-pixel cloners, make them clone gas and put some lava at the bottom.
Semaphorover 6 years ago
Literally unplayable, exploding gas goes through thick solid walls without even damaging the wall.<p>Awesome game, I love the options :)
emilfihlmanover 6 years ago
There&#x27;s an off by one error on sides, fire and it&#x27;s effects can go along the sides.
Kyeover 6 years ago
You can create a little self-sustaining motion with a cloner covered in something that falls over a lake of acid.<p><a href="https:&#x2F;&#x2F;sandspiel.club&#x2F;#IbQHF3edJmCy1dLJAWO8" rel="nofollow">https:&#x2F;&#x2F;sandspiel.club&#x2F;#IbQHF3edJmCy1dLJAWO8</a>
lstoddover 6 years ago
This is great. I&#x27;m almost tempted to redo this with believable thermodynamics.
评论 #18696704 未加载
glitchcover 6 years ago
Working in Safari on iOS 12
itsjustme321over 6 years ago
Reminds me of The Powder Toy, which is great by the way, lots of fun!
sj4nzover 6 years ago
Drop oil on lava.<p>The effect is worth it.
评论 #18696485 未加载
评论 #18696508 未加载
jl6over 6 years ago
I remember watching Confetti Factory on After Dark, which I think of as a primitive precursor to this. Must have been very early 1990s. Any earlier examples?
johnisgoodover 6 years ago
I love fungus. It makes the plant grow. Pour some acid on it, it will regrow! On the other hand, fire is pretty destructive.<p>You know what feature I miss? Fast-forwarding!
nevesover 6 years ago
Does this game have any objective? I didn&#x27;t get it.
评论 #18698629 未加载
_57jbover 6 years ago
This was mesmerizing. Well done, thoroughly enjoyed it.
avipover 6 years ago
Wind effect is beautiful and looks like a Julia set.
anoncowover 6 years ago
Really liked lava and fire. I don’t know why gravity doesn’t affect the blue stuff. Can you disable page swipe gestures on mobile chrome?
ok-replover 6 years ago
I&#x27;ve always been fascinated by these simulations. Can anybody give a rough overview of how these (I guess?) fluid simulations work?
mgoetzkeover 6 years ago
Great ! Was just looking for something like this for a snow effect. I used to do something with falling snow on text for Christmas.
sadjadover 6 years ago
It&#x27;s weird, but I can&#x27;t share the link on Twitter, and goo.gl shortlink doesn&#x27;t work either.<p>Does anyone have the same problem?
mattdeboardover 6 years ago
Weird, I was just looking at this today. Very cool project! I have a feature idea on my stack of ideas I hope to get to
windlessstormover 6 years ago
Site is got down of big HN hug I guess
skykoolerover 6 years ago
This is excellent fun. I&#x27;m kind of curious though as to why blowing wind at the dust ignites it?
评论 #18697621 未加载
shittyadminover 6 years ago
The smoke and explosion effects are amazing, better than any other FSG I&#x27;ve tried. Very cool.
ddingusover 6 years ago
I had fun with this. Great effects. Lava, lol.<p>I got a lot going, 25fps Samsung Note 8, Power Saving Mode<p>32 fps Performance Mode
Santosh83over 6 years ago
Will activating WebRender improve framerates?<p>Not that it needs improving anyway... just curious.
评论 #18696877 未加载
评论 #18696640 未加载
gigatexalover 6 years ago
Fun little game! 42FPS on my iPhone X, too. And best of all no excessive heat
评论 #18697250 未加载
评论 #18697299 未加载
ecabukover 6 years ago
Lava cannot melt ice? :D
profalseidolover 6 years ago
Ice can hold lava?<p>btw, adding oil over lava produces a very cool smoke effect.
miguelmotaover 6 years ago
This is incredible. Runs flawlessly and surprisingly smooth
nablaoperatorover 6 years ago
Reminds me of Clonk!
jtsiskinover 6 years ago
I get 1-2 FPS running this in Chrome on macOS Mojave.
评论 #18697540 未加载
评论 #18697215 未加载
jeffrallenover 6 years ago
Lava should make water turn to gas and blow up!
bredrenover 6 years ago
I like the smoke when you burn the fungus.
geitirover 6 years ago
This is fun
omaniover 6 years ago
nothing happens on mobile
评论 #18696400 未加载
评论 #18696393 未加载
Evidloover 6 years ago
Fun, but a bit blurry.
hujunover 6 years ago
create some plants, and drop some seed on it
gworfover 6 years ago
This is fun!
hyperpalliumover 6 years ago
Is it really a &quot;game&quot; if there&#x27;s no goal or &quot;win&quot; condition? Or is it a &quot;webtoy&quot; or &quot;simulation&quot; (or... &quot;sandbox&quot;. Think it&#x27;s a sandbox).
评论 #18696491 未加载
评论 #18696676 未加载
评论 #18698077 未加载
评论 #18696925 未加载
评论 #18697418 未加载
评论 #18696449 未加载
PavlovsCatover 6 years ago
<a href="https:&#x2F;&#x2F;sandspiel.club&#x2F;#A6xPmAP4TSEpcwThAFSB" rel="nofollow">https:&#x2F;&#x2F;sandspiel.club&#x2F;#A6xPmAP4TSEpcwThAFSB</a><p>erase the thingy to the right, and the planets on the left grow upwards again.
评论 #18696926 未加载
choochootrain6over 6 years ago
I&#x27;ve never played Powder Toy, but I do remember playing something called Powder Game. Are they related in some way?
the_other_guyover 6 years ago
This is the most satisfying thing I&#x27;ve ever seen on HN!