I started playing around with the shallow water equations and got to something that's maybe a little bit fun. Arrow keys make waves, Z switches boundaries between (approximately) open and reflecting. My implementation mostly follows https://graphics.ethz.ch/Downloads/Publications/Tutorials/2008/Mue08/coursenotes.pdf .
Current limitations/known bugs:
- Dissipates energy rapidly, although you'll probably only notice this if the boundaries are reflective.
- No handling of dry regions. Weird things may happen if depth goes to 0!
- Weird oscillations around both (nearly-)dry regions and shocks/big elevation changes. Not sure yet how much of this is attributable to bugs vs. limitations of the discretization I'm using.
- Liquid volume is not conserved. Not really a meaningful concept with open boundaries, but pretty noticeable with reflective boundaries.
- No wave breaking etc. Shallow water equations are a heightfield model and I don't think I'll get around to full liquids on PICO-8 any time soon. :)
I hope this cart is fun to play with! I'm hoping to fix a few of the items above, clean up the graphics a bit, and maybe find a way to build a little bit of a game around these dynamics.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/25532/icon.png)
Hu... with open edges I was able to empty the ocean ;)
Nice though!
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/24137/5_cloud.png)
Hmm.... There's a term in there to slowly bring the edges back up to halfway up the screen if you leave the sim alone. (The open boundary implementation here is kind of a hack in any case -- so what's one more hack to make it work better?) I'm curious though: when you emptied the ocean, did it happen suddenly after depth going to 0 somewhere, suddenly after a large oscillation appeared somewhere, or just kind of gradually?
[Please log in to post a comment]