Skip to content

aidenx11/Java-Pixel-Physics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Pixel Physics

Note: The web version has a smaller screen size and resolution than the desktop version to save performance.

Overview

Inspired by the various falling sand simulators from when I was a kid such as The Sandbox, and more modern games such as Noita, I aimed to create a simulation of my own in Java using the LibGDX framework.

DemoVideoV2.mp4

As of now, the simulation has basic gasses, water and lava, and a small variety of solids that interact with gravity. There is logic for objects burning, getting wet, melting, and settling. There is also logic for gravity, acceleration and basic concepts of momentum/inertia.

Most of the logic is performed by manipulating a 2D array of "element" objects, changing their positions in the array and their individual fields as needed for their behavior. Each frame, every element checks other elements surrounding itself and decides what it needs to do. For more information on this design pattern, see the concept of Cellular Automata.

Optimizations have been made using chunks. The screen is separated into a grid of chunks, and each chunk will only update the elements inside of it if it needs to. Support for multithreading is possible, but not necessary yet.