fix: decreased friction, clippy, fmt
This commit is contained in:
parent
683bfa2c99
commit
a735ae7713
1 changed files with 23 additions and 48 deletions
71
src/game.rs
71
src/game.rs
|
@ -1,4 +1,5 @@
|
||||||
#![allow(clippy::precedence)]
|
#![allow(clippy::precedence)]
|
||||||
|
#![allow(clippy::too_many_arguments)]
|
||||||
|
|
||||||
use crate::AppState;
|
use crate::AppState;
|
||||||
|
|
||||||
|
@ -187,7 +188,7 @@ fn spawn_character(
|
||||||
.insert(Velocity::default())
|
.insert(Velocity::default())
|
||||||
.insert(GravityScale(10.0))
|
.insert(GravityScale(10.0))
|
||||||
.insert(LockedAxes::ROTATION_LOCKED)
|
.insert(LockedAxes::ROTATION_LOCKED)
|
||||||
.insert(Friction::new(1.0))
|
.insert(Friction::new(0.8))
|
||||||
.insert(Damping {
|
.insert(Damping {
|
||||||
linear_damping: 0.5,
|
linear_damping: 0.5,
|
||||||
angular_damping: 0.5,
|
angular_damping: 0.5,
|
||||||
|
@ -267,7 +268,7 @@ fn keyboard_input_system(
|
||||||
current_level: Res<CurrentLevel>,
|
current_level: Res<CurrentLevel>,
|
||||||
mut characters: Query<(
|
mut characters: Query<(
|
||||||
&CharacterId,
|
&CharacterId,
|
||||||
&mut Velocity,
|
&mut Velocity,
|
||||||
&mut ExternalImpulse,
|
&mut ExternalImpulse,
|
||||||
&mut ExternalForce,
|
&mut ExternalForce,
|
||||||
&Children,
|
&Children,
|
||||||
|
@ -285,21 +286,11 @@ fn keyboard_input_system(
|
||||||
audio.play(dsp_assets.graph(&sine_wave));
|
audio.play(dsp_assets.graph(&sine_wave));
|
||||||
|
|
||||||
let selected = if let Some(selected_character_id) = &mut selected_character_id.0 {
|
let selected = if let Some(selected_character_id) = &mut selected_character_id.0 {
|
||||||
if let Some((
|
if let Some((_character_id, _velocity, _impulse, _force, children)) = characters
|
||||||
_character_id,
|
.iter_mut()
|
||||||
_velocity,
|
.find(|(character_id, _velocity, _impulse, _force, _children)| {
|
||||||
_impulse,
|
*character_id == selected_character_id
|
||||||
_force,
|
}) {
|
||||||
children
|
|
||||||
|
|
||||||
)) = characters.iter_mut().find(|(
|
|
||||||
character_id,
|
|
||||||
_velocity,
|
|
||||||
_impulse,
|
|
||||||
_force,
|
|
||||||
_children
|
|
||||||
|
|
||||||
)| { *character_id == selected_character_id }) {
|
|
||||||
effect
|
effect
|
||||||
.get_mut(children[0])
|
.get_mut(children[0])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -319,20 +310,11 @@ fn keyboard_input_system(
|
||||||
CharacterId(0)
|
CharacterId(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some((
|
if let Some((_character_id, _velocity, _impulse, _force, children)) = characters
|
||||||
_character_id,
|
.iter_mut()
|
||||||
_velocity,
|
.find(|(character_id, _velocity, _impulse, _force, _children)| {
|
||||||
_impulse,
|
**character_id == selected
|
||||||
_force,
|
}) {
|
||||||
children
|
|
||||||
)) = characters.iter_mut().find(|(
|
|
||||||
character_id,
|
|
||||||
_velocity,
|
|
||||||
_impulse,
|
|
||||||
_force,
|
|
||||||
_children
|
|
||||||
)| **character_id == selected)
|
|
||||||
{
|
|
||||||
effect
|
effect
|
||||||
.get_mut(children[0])
|
.get_mut(children[0])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -342,25 +324,18 @@ fn keyboard_input_system(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let right_pressed: bool = keyboard_input.pressed(KeyCode::Right) || keyboard_input.pressed(KeyCode::D);
|
let right_pressed: bool =
|
||||||
let left_pressed: bool = keyboard_input.pressed(KeyCode::Left) || keyboard_input.pressed(KeyCode::A);
|
keyboard_input.pressed(KeyCode::Right) || keyboard_input.pressed(KeyCode::D);
|
||||||
|
let left_pressed: bool =
|
||||||
|
keyboard_input.pressed(KeyCode::Left) || keyboard_input.pressed(KeyCode::A);
|
||||||
|
|
||||||
if let Some(selected_character_id) = &selected_character_id.0 {
|
if let Some(selected_character_id) = &selected_character_id.0 {
|
||||||
if let Some((
|
if let Some((_character_id, mut velocity, _impulse, _force, _children)) =
|
||||||
_character_id,
|
characters.iter_mut().find(
|
||||||
mut velocity,
|
|(character_id, _velocity, _impulse, _force, _children)| {
|
||||||
mut impulse,
|
*character_id == selected_character_id
|
||||||
mut force,
|
},
|
||||||
_children
|
) {
|
||||||
|
|
||||||
)) = characters.iter_mut().find(|(
|
|
||||||
character_id,
|
|
||||||
_velocity,
|
|
||||||
_impulse,
|
|
||||||
_force,
|
|
||||||
_children
|
|
||||||
|
|
||||||
)| { *character_id == selected_character_id }) {
|
|
||||||
velocity.linvel.x = 200. * (right_pressed as i8 - left_pressed as i8) as f32;
|
velocity.linvel.x = 200. * (right_pressed as i8 - left_pressed as i8) as f32;
|
||||||
|
|
||||||
if keyboard_input.just_pressed(KeyCode::Space) {
|
if keyboard_input.just_pressed(KeyCode::Space) {
|
||||||
|
|
Loading…
Reference in a new issue