Fix faster diagonal acceleration for the player
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:
Michael Bradley 2025-05-24 00:43:44 -04:00
parent 10b525e4c7
commit 0896ccf691
Signed by: MichaelBradley
SSH key fingerprint: SHA256:o/aaeYtRubILK7OYYjYP12DmU7BsPUhKji1AgaQ+ge4
3 changed files with 41 additions and 18 deletions

View file

@ -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,
),
));