Skip to content

Commit

Permalink
Add walking animation to player when sliding in
Browse files Browse the repository at this point in the history
  • Loading branch information
PurityLake committed Dec 11, 2023
1 parent 555f51d commit 3f4e80f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,24 @@ fn add_collisions(mut commands: Commands, player: Query<Entity, With<PlayerDirec
fn slide_in_player(
time: Res<Time>,
mut gameplay_start: ResMut<GameplayStart>,
mut player: Query<(&PlayerDirection, &mut Transform)>,
mut player: Query<(
&PlayerDirection,
&mut Transform,
&mut Handle<TextureAtlas>,
&mut AnimationComponent,
)>,
) {
if !gameplay_start.play_inplace {
for (_, mut player_transform) in player.iter_mut() {
for (_, mut player_transform, mut handle, mut anim) in player.iter_mut() {
if anim.state == AnimState::Idle {
anim.state = AnimState::Walking;
*handle = anim.get_handle().unwrap();
}
player_transform.translation.x += 200.0 * time.delta_seconds();
if player_transform.translation.x >= gameplay_start.player_endpos.x {
gameplay_start.play_inplace = true;
anim.state = AnimState::Idle;
*handle = anim.get_handle().unwrap();
}
}
}
Expand Down

0 comments on commit 3f4e80f

Please sign in to comment.