Fix faster diagonal acceleration for the player
All checks were successful
CI / Formatting (push) Successful in 1m27s
All checks were successful
CI / Formatting (push) Successful in 1m27s
Also always accelerate the player using the same force, so that bigger players aren't overpowered.
This commit is contained in:
parent
10b525e4c7
commit
0896ccf691
3 changed files with 41 additions and 18 deletions
|
@ -12,7 +12,7 @@ use bevy_rand::prelude::{GlobalEntropy, WyRand};
|
|||
use rand::Rng as _;
|
||||
|
||||
use super::{
|
||||
objects::{Ball, Player, Wall},
|
||||
objects::{Ball, Player, Radius, Wall},
|
||||
rng::thread_rng,
|
||||
};
|
||||
|
||||
|
@ -32,6 +32,7 @@ pub fn setup_from_seed(mut commands: Commands, mut rng: GlobalEntropy<WyRand>) {
|
|||
));
|
||||
}
|
||||
|
||||
/// I mean, a camera is technically a user interface, I guess
|
||||
pub fn setup_ui(mut commands: Commands) {
|
||||
commands.spawn((Name::new("Camera"), Camera2d, IsDefaultUiCamera));
|
||||
}
|
||||
|
@ -44,10 +45,12 @@ pub fn setup_player(
|
|||
) {
|
||||
let mut random = thread_rng();
|
||||
|
||||
let circle = Circle::new(random.random_range(BALL_SIZES));
|
||||
let radius = random.random_range(BALL_SIZES);
|
||||
let circle = Circle::new(radius);
|
||||
commands.spawn((
|
||||
Name::new("Player"),
|
||||
Player,
|
||||
Radius(radius),
|
||||
Collider::from(circle),
|
||||
Mesh2d(meshes.add(circle)),
|
||||
MeshMaterial2d(materials.add(Color::from(LIME_400))),
|
||||
|
@ -64,18 +67,18 @@ pub fn setup_balls(
|
|||
let mut random = thread_rng();
|
||||
|
||||
for i in 0..BALL_COUNT {
|
||||
let circle = Circle::new(random.random_range(BALL_SIZES));
|
||||
let radius = random.random_range(BALL_SIZES);
|
||||
let circle = Circle::new(radius);
|
||||
commands.spawn((
|
||||
Name::new(format!("Ball[{i}]")),
|
||||
Ball,
|
||||
Radius(radius),
|
||||
Collider::from(circle),
|
||||
Mesh2d(meshes.add(circle)),
|
||||
MeshMaterial2d(materials.add(Color::from(RED_400))),
|
||||
Transform::from_xyz(
|
||||
random.random::<f32>() * (region.0 - 2.0 * circle.radius) + circle.radius
|
||||
- region.0 / 2.0,
|
||||
random.random::<f32>() * (region.1 - 2.0 * circle.radius) + circle.radius
|
||||
- region.1 / 2.0,
|
||||
random.random::<f32>() * (region.0 - 2.0 * radius) + radius - region.0 / 2.0,
|
||||
random.random::<f32>() * (region.1 - 2.0 * radius) + radius - region.1 / 2.0,
|
||||
0.0,
|
||||
),
|
||||
));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue