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