Satisfying sand falling thingy :) banner

Satisfying sand falling thingy :)

10 devlogs
9h 10m 6s

One of those cool looking gravtiy sand things built in C and raylib

This project uses AI

Ai was used to help me understand the concepts of how the stuff actually works

Demo Repository

Loading README...

nmsoukmandjiev007

Shipped this project!

I built a falling sand sim for week 3 of lockin
It was written entirely in C using raylib as the graphics library, and compiles to wasm for it to exist on the interweb
It includes 5 different materials that all interact with each other, those being sand rock water lava and air.
It was a fun little project to make this as i used to love using the online sandbox ones when i was younger
It was fun to also get it to run fairly well on the web, as its quite quick and leaves a small memory footprint!

Hope you enjoy!

FYI lava moving slowly is an intentional design choice, your game isnt lagging!!

nmsoukmandjiev007

Added lava!!!
Lava is a very slow and viscous material, which means it falls quite slowly. When it interacts with water, it forms rock!
It also shares the same filling properties as water, since it wouldn’t make sense to make a whole new way to make it fill.
The issue came with performance though….
Since lava has many new properties and interactions, that meant that lava had quite a lot of code run for it every frame, and when theres a lot of lava particles it SEVERELY destroyed performance.
I spent quite a while optimising it, and whilst it does hitch sometimes, it runs much better than before!

Im sure that also adding a compiler flag would make it good enough for a rock solid 60fps!

I also spent some time just making the sand falling a bit more accurate, which was fun as it made the water-sand interaction actually look good

Im probably done for now with this project, but i’ll see if i want to continue working on it!

Attachment
0
nmsoukmandjiev007

Finished the web build!!
you can visit it here https://nikoi008.github.io/Falling-sand-sim/
I found an issue with the water and sand interaction so im working on that at the moment!
The way i got it on the web is by using emscriptem and then compiling in wasm, which is a really nice benefit when working in raylib!!!

The only thing i have planned is probs 1 or 2 more blocks and then this is probably shipping worthy!

Attachment
0
nmsoukmandjiev007

Added colour variation!!
I made it super efficient as it literally only stores 1 byte per colour, meaning that it saves 7x more memory compared to if i were to do it as RGBA (1 byte for R, 1 for G, and 1 for B and 4bytes for alpha)!!
This means it only uses 40kb of memory instead of the usual 210kb, which is a very miniscule number anyways, but its good to optimise wherever you can, especially since this is an optimasion that is isolated from the rest of the code meaning that im not actually racking up any sort of technical debt!!!
It also makes it look much cooler and more realistic which im happy about too!
Todo!
Web build
Readme
More blocks if i have the time!

Attachment
0
nmsoukmandjiev007

Added a little UI where people can select the type of block they want!
I also added keyboard shortcuts for each of these (1-4), but that isn’t anything crazy.
Its already looking polished but im kinda running out of ideas lol
I might change the way the blocks look so they look more realistic rather than a single blob of yellow
Todo!
Reset button (maybe not really necessary because of erase?)
Web build
Readme
Cooler looking blocks!

Thats about it for this devlog tbh but i hope i can come up with more ideas!!!

Attachment
0
nmsoukmandjiev007

The non- gravity floaty rock things work!!
its really fun to just make a plinko style arena with this and see the water flowing down!
Thats about it for this feature lol but what im planning to implement now is

A UI with tooltips!
Grid reset
Web build :O
More cool blocks!

Attachment
0
nmsoukmandjiev007

Added a brush and got working on the solid floaty blocks!!!
The brush was fairly straightforward to make, its just that im having issues with the blocks colliding with the solid block where they would kinda tweak out, so im trying to get that working!

Attachment
0
nmsoukmandjiev007

I got water done!!!
This was SUPER confusing because i kept messing up the water logic and also the gravity logic and also the interaction between sand and water, but in the end we got there!!!
For those wondering, water shares the same logic as sand, except it also needs to move horizontally to fill in any spaces, and cannot just crawl over a mountain of sand.
Its currently being controlled by keys! 0 is air, 1 is sand and water is 2
It works really smoothly and im really happy with how its working so far!!

Todo!
UI!
Grid reset
Larger brush sizes!
More blocks (currently planning to make just a solid block that doesnt move)

Attachment
0
nmsoukmandjiev007

Got started on this project for week 3 of lockin!!
This was mainly me experimenting and lookin at other peoples code, and i managed to reproduce a very nice looking falling sand type thing!
It is honestly fairly simple to make once you boil it down into basics lol. you first try to apply gravity downwards, if the sand is already grounded try to make it go left, if the left is blockaded make it go right!
Right now its just a 3x3 brush that just pushes downwards, but i have plans to make it enlargen and also have more cool blocks!

Todo!!
Variable size of brush
Water
An actual UI sob-ios
A way to reset the grid!

Since im most likely only going to spend 10 hours total on this ill keep the scope fairly simple!
Enjoy the recording!

0