This is a simple "falling sand" simulation written in Java using Swing for the GUI. The project was inspired by the famous YouTube channel "Coding Train", which featured a similar simulation built with a JavaScript graphics library. Unlike the JavaScript version, which could rely on built-in physics and rendering, this Java version required implementing the sand physics logic from scratch.
I translated the core ideas from the JavaScript code to Java, and at the time, I was only familiar with Swing for building graphical user interfaces, so that's what I used here.
- Click or drag the mouse to place colorful sand particles.
- The sand falls and interacts with other particles, simulating gravity and basic physics.
- The simulation runs in real-time with a simple animation loop.
- Clone or download the repository.
- Compile the Java files in the
srcdirectory. - Run the
Appclass to start the simulation.
Enjoy experimenting with the falling sand and feel free to fix or modify!