We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6611a98 commit 2858ad3Copy full SHA for 2858ad3
src/components/player.rs
@@ -126,4 +126,8 @@ impl Player {
126
None
127
}
128
129
+
130
+ pub fn move_x(&mut self, x: f32) {
131
+ self.lerp_to = Some(lerp(self.pos_x, x, 2.5));
132
+ }
133
src/game.rs
@@ -492,12 +492,12 @@ impl Game {
492
pub fn key_press(&mut self, keycode: KeyCode) -> Option<crate::Screen> {
493
match keycode {
494
KeyCode::Left => {
495
- self.player.pos_x -= 10.;
+ self.player.move_x(self.player.pos_x - 10.);
496
497
self.player.set_direction(Direction::Left);
498
499
KeyCode::Right => {
500
- self.player.pos_x += 10.;
+ self.player.move_x(self.player.pos_x + 10.);
501
502
self.player.set_direction(Direction::Right);
503
0 commit comments