Make only playable area seeded
This commit is contained in:
parent
10a6bad336
commit
10b525e4c7
2 changed files with 8 additions and 11 deletions
|
@ -24,13 +24,8 @@ const DIMENSION_SIZES: Range<f32> = 500.0..2000.0;
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
pub struct PlayableArea(f32, f32);
|
pub struct PlayableArea(f32, f32);
|
||||||
|
|
||||||
/// The size of the player character
|
|
||||||
#[derive(Resource)]
|
|
||||||
pub struct PlayerSize(f32);
|
|
||||||
|
|
||||||
/// Initialize deterministic values
|
/// Initialize deterministic values
|
||||||
pub fn setup_pseudo_random(mut commands: Commands, mut rng: GlobalEntropy<WyRand>) {
|
pub fn setup_from_seed(mut commands: Commands, mut rng: GlobalEntropy<WyRand>) {
|
||||||
commands.insert_resource(PlayerSize(rng.random_range(BALL_SIZES)));
|
|
||||||
commands.insert_resource(PlayableArea(
|
commands.insert_resource(PlayableArea(
|
||||||
rng.random_range(DIMENSION_SIZES),
|
rng.random_range(DIMENSION_SIZES),
|
||||||
rng.random_range(DIMENSION_SIZES),
|
rng.random_range(DIMENSION_SIZES),
|
||||||
|
@ -46,9 +41,10 @@ pub fn setup_player(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
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((
|
commands.spawn((
|
||||||
Name::new("Player"),
|
Name::new("Player"),
|
||||||
Player,
|
Player,
|
||||||
|
@ -66,6 +62,7 @@ pub fn setup_balls(
|
||||||
region: Res<PlayableArea>,
|
region: Res<PlayableArea>,
|
||||||
) {
|
) {
|
||||||
let mut random = thread_rng();
|
let mut random = thread_rng();
|
||||||
|
|
||||||
for i in 0..BALL_COUNT {
|
for i in 0..BALL_COUNT {
|
||||||
let circle = Circle::new(random.random_range(BALL_SIZES));
|
let circle = Circle::new(random.random_range(BALL_SIZES));
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
|
|
@ -7,7 +7,7 @@ mod game;
|
||||||
use game::{
|
use game::{
|
||||||
runtime::{move_camera, move_player, quit, zoom_camera},
|
runtime::{move_camera, move_player, quit, zoom_camera},
|
||||||
seed::Seed,
|
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.
|
/// The initial configuration passed to the game's setup functions.
|
||||||
|
@ -39,9 +39,9 @@ impl Plugin for AppSettings {
|
||||||
.add_systems(
|
.add_systems(
|
||||||
Startup,
|
Startup,
|
||||||
(
|
(
|
||||||
setup_pseudo_random,
|
setup_from_seed,
|
||||||
setup_ui,
|
setup_ui,
|
||||||
(setup_player, setup_balls, setup_walls).after(setup_pseudo_random),
|
(setup_player, setup_balls, setup_walls).after(setup_from_seed),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue