Simple galaxy simulation in Rust
-
Attempts to handle collisions by checking their relative velocities
-
Traces future paths by simulating seperately (as shown below)
The default configuration file looks like:
galaxies:
- star:
mass: 2000000.0
color: [1.0, 1.0, 0.0, 1.0]
planets:
distance:
min: 10
max: 30
mass:
min: 1
max: 50
number: 250
position: [60.0, 60.0]
direction: 1.0
- star:
mass: 1000000.0
color: [1.0, 1.0, 0.0, 1.0]
planets:
distance:
min: 10
max: 30
mass:
min: 1
max: 50
number: 250
position: [-60.0, -60.0]
direction: -1.0
scale: 1.0
time_scale: 1.0This has 3 components:
galaxies, which refers to the structures that will be generated. Each contains information about the central star, planets' distances and masses, the position in the world and the direction of the planets' orbits. Planets will then be generated randomly about the star with the given velocityv = sqrt((M_star+m_planet)/distance).scalerefers to the screen:real ratio when drawing. Bigger numbers are more zoomed in, smaller numbers are more zoomed out.1time_scalerefers to the passing of time. This, alongside the frame rate, affects the simulation's speed. All forces and velocities are multiplied bydt * time_scale2
1: Use Z to zoom out, X to zoom in
2: Use A to slow down time, S to speed up time.
You can also use the arrow keys to move around.
As always, use
cargo runTo build and run.

