diff --git a/Cargo.toml b/Cargo.toml index 4e01422..08e89be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" [dependencies] bevy = { version = "0.16", features = ["dynamic_linking"] } bevy-inspector-egui = "0.32.0" +rand = "0.9.2" diff --git a/src/asteroids.rs b/src/asteroids.rs index d389ce2..c1d09e4 100644 --- a/src/asteroids.rs +++ b/src/asteroids.rs @@ -1,4 +1,5 @@ use std::time::Duration; +use rand::SeedableRng; /// This is the module containing all the rock-related things /// not... not the whole game. @@ -17,6 +18,7 @@ pub enum AsteroidSize { #[derive(Resource)] pub struct AsteroidSpawner { + rng: std::sync::Mutex, timer: Timer, // TODO: Configurables? // - interval @@ -27,6 +29,7 @@ pub struct AsteroidSpawner { impl AsteroidSpawner { pub fn new() -> Self { Self { + rng: std::sync::Mutex::new(rand::rngs::StdRng::from_seed(crate::config::RNG_SEED)), timer: Timer::new(Duration::from_secs(3), TimerMode::Repeating), } } diff --git a/src/config.rs b/src/config.rs index fd585af..9f0aa61 100644 --- a/src/config.rs +++ b/src/config.rs @@ -16,3 +16,5 @@ pub(crate) const ASTEROID_SMALL_COLOR: Color = Color::srgb(1.0, 0., 0.); pub(crate) const SHIP_THRUST: f32 = 1.0; pub(crate) const SHIP_ROTATION: f32 = 0.1; // +/- rotation speed in... radians per frame + +pub const RNG_SEED: [u8; 32] = *b"12345678909876543210123456789098";