Make only playable area seeded

This commit is contained in:
Michael Bradley 2025-05-23 23:49:11 -04:00
parent 10a6bad336
commit 10b525e4c7
Signed by: MichaelBradley
SSH key fingerprint: SHA256:o/aaeYtRubILK7OYYjYP12DmU7BsPUhKji1AgaQ+ge4
2 changed files with 8 additions and 11 deletions

View file

@ -24,13 +24,8 @@ const DIMENSION_SIZES: Range<f32> = 500.0..2000.0;
#[derive(Resource)]
pub struct PlayableArea(f32, f32);
/// The size of the player character
#[derive(Resource)]
pub struct PlayerSize(f32);
/// Initialize deterministic values
pub fn setup_pseudo_random(mut commands: Commands, mut rng: GlobalEntropy<WyRand>) {
commands.insert_resource(PlayerSize(rng.random_range(BALL_SIZES)));
pub fn setup_from_seed(mut commands: Commands, mut rng: GlobalEntropy<WyRand>) {
commands.insert_resource(PlayableArea(
rng.random_range(DIMENSION_SIZES),
rng.random_range(DIMENSION_SIZES),
@ -46,9 +41,10 @@ pub fn setup_player(
mut commands: Commands,
mut materials: ResMut<Assets<ColorMaterial>>,
mut meshes: ResMut<Assets<Mesh>>,
radius: Res<PlayerSize>,
) {
let circle = Circle::new(radius.0);
let mut random = thread_rng();
let circle = Circle::new(random.random_range(BALL_SIZES));
commands.spawn((
Name::new("Player"),
Player,
@ -66,6 +62,7 @@ pub fn setup_balls(
region: Res<PlayableArea>,
) {
let mut random = thread_rng();
for i in 0..BALL_COUNT {
let circle = Circle::new(random.random_range(BALL_SIZES));
commands.spawn((

View file

@ -7,7 +7,7 @@ mod game;
use game::{
runtime::{move_camera, move_player, quit, zoom_camera},
seed::Seed,
setup::{setup_balls, setup_player, setup_pseudo_random, setup_ui, setup_walls},
setup::{setup_balls, setup_from_seed, setup_player, setup_ui, setup_walls},
};
/// The initial configuration passed to the game's setup functions.
@ -39,9 +39,9 @@ impl Plugin for AppSettings {
.add_systems(
Startup,
(
setup_pseudo_random,
setup_from_seed,
setup_ui,
(setup_player, setup_balls, setup_walls).after(setup_pseudo_random),
(setup_player, setup_balls, setup_walls).after(setup_from_seed),
),
)
.add_systems(