This is a simple particle simulator implemented in Java. It uses Swing for the graphical user interface and Java's built-in concurrency utilities for the simulation logic.
-
Open the
jar
file in thesrc
directory, two windows should pop-up (canvas + inputs) -
Click on the dropdown to change input type
Single Particle
,Constant Velocity + Varying Angle
,Constant Start Points + Varying Angle
,Constant Start Points + Varying Velocity
,Add Wall
- As for all types, simply input the required fields (X, Y, angle, velocity, etc.)
- Click on the
Add
button after completing the inputs
-
Clear all of the
Particles
by clicking on theClear Particles
button -
Clear all of the
Walls
by clicking on theClear Walls
button -
Close either of the windows to stop the program
- Java Development Kit (JDK) 8 or later
- Open a terminal/command prompt.
- Navigate to the directory containing the
src
folder. - Compile the Java files using the
javac
command:
javac src/*.java
This will compile all the Java files in the src
directory and create corresponding .class
files.
After compiling the program, you can run it using the java
command. The main class of the program is ParticleSimulator
.
java src/ParticleSimulator
This will start the particle simulator. You can interact with the program using the graphical user interface.
- After compiling the program, navigate to the
src
directory:
cd src
- Create a manifest file named
Manifest.txt
with the following content:
Main-Class: ParticleSimulator
Note the extra newline at the end of the file.
This tells the JAR file which class to run when it's executed.
- Create the JAR file using the
jar
command:
jar cvfm ParticleSimulator.jar Manifest.txt *.class
This will create a JAR file named ParticleSimulator.jar
that includes all the .class
files in the current directory and uses the manifest file you created.
After creating the JAR file, you can run it using the java
command:
java -jar ParticleSimulator.jar
This will start the particle simulator just like before, but now you're running it from a single JAR file instead of multiple .class
files.
- Add particles with fixed velocity and angle.
- Add particles with a fixed start point and varying angle.
- Add particles with a fixed start point and varying velocity.
- Add walls for the particles to bounce off.
- Clear all particles or walls.