summaryrefslogtreecommitdiff
path: root/server/protocol/src/movement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/protocol/src/movement.rs')
-rw-r--r--server/protocol/src/movement.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/server/protocol/src/movement.rs b/server/protocol/src/movement.rs
index 286c7f6a..5525c5e6 100644
--- a/server/protocol/src/movement.rs
+++ b/server/protocol/src/movement.rs
@@ -17,7 +17,7 @@
*/
use crate::{
glam::{IVec2, Vec2},
- PacketS,
+ PacketS, PlayerID,
};
use std::collections::HashSet;
@@ -48,13 +48,7 @@ impl MovementBase {
rotation: 0.,
}
}
- pub fn update(
- &mut self,
- map: &HashSet<IVec2>,
- direction: Vec2,
- mut boost: bool,
- dt: f32,
- ) -> PacketS {
+ pub fn update(&mut self, map: &HashSet<IVec2>, direction: Vec2, mut boost: bool, dt: f32) {
let direction = direction.clamp_length_max(1.);
if direction.length() > 0.1 {
self.facing = direction + (self.facing - direction) * (-dt * 10.).exp();
@@ -73,11 +67,14 @@ impl MovementBase {
self.position += self.velocity * dt;
self.velocity *= (-dt * PLAYER_FRICTION).exp();
collide_player_tiles(self, map);
+ }
+ pub fn movement_packet(&self, direction: Vec2, player: PlayerID) -> PacketS {
PacketS::Movement {
pos: Some(self.position),
boosting: self.boosting,
direction,
+ player,
}
}