An N-body simulation in Rust using the bevy crate for rendering and bigbang crate for the n-body calculations.
Note: I made this shortly after bevy was initially released so it's a bit out of date now. Also, I haven't really worked with ECS before, so you probably shouldn't use this as an example of how to structure a bevy game.
Clone the repo, and run cargo build --release
. The executable will be under target/release/
.
Usage: bevy-nbody [-n <num-bodies>] [-t <time-step>] [-w <width>] [-h <height>] [-s <scale>]
n-body simulation in bevy using bigbang
Options:
-n, --num-bodies number of bodies in the simulation
-t, --time-step granularity of simulation (how much each frame impacts
movement)
-w, --width initial width of spawned window
-h, --height initial height of spawned window
-s, --scale initial scale of view (bigger = more zoomed out)
--help display usage information
key | control |
---|---|
R | reset the simulation |
Space | pause / resume the simulation |
Left Click | hold and move mouse to pan the view |
Middle Click | hold and move mouse up and down to zoom in and out |
Right Click | click on a body to focus the camera on that body |