feat: Basic player implementation

This commit is contained in:
Alexey 2026-04-10 13:35:44 +03:00
commit e4b1475c48
9 changed files with 830 additions and 54 deletions

25
src/player/systems.rs Normal file
View file

@ -0,0 +1,25 @@
//! Player systems
use super::*;
/// Do something based on [PlayerInput]
pub fn handle_input(
time: Res<Time>,
player_query: Query<(
&Player,
&ActionState<PlayerInput>,
&mut KinematicCharacterController,
&mut Sprite,
)>,
) {
for (player, action_state, mut controller, mut sprite) in player_query {
let direction = action_state.clamped_value(&PlayerInput::Move);
controller.translation = Some(vec2(direction * player.speed * time.delta_secs(), 0.));
if direction != 0. {
sprite.flip_x = direction < 0.;
}
}
}