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.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/server/protocol/src/movement.rs b/server/protocol/src/movement.rs
index 5525c5e6..dad9d300 100644
--- a/server/protocol/src/movement.rs
+++ b/server/protocol/src/movement.rs
@@ -29,6 +29,7 @@ const BOOST_DURATION: f32 = 0.3;
const BOOST_RESTORE: f32 = 0.5;
pub struct MovementBase {
+ pub direction: Vec2,
pub position: Vec2,
pub facing: Vec2,
pub rotation: f32,
@@ -41,6 +42,7 @@ impl MovementBase {
pub fn new(position: Vec2) -> Self {
Self {
position,
+ direction: Vec2::ZERO,
facing: Vec2::X,
velocity: Vec2::ZERO,
boosting: false,
@@ -49,7 +51,7 @@ impl MovementBase {
}
}
pub fn update(&mut self, map: &HashSet<IVec2>, direction: Vec2, mut boost: bool, dt: f32) {
- let direction = direction.clamp_length_max(1.);
+ self.direction = direction.clamp_length_max(1.);
if direction.length() > 0.1 {
self.facing = direction + (self.facing - direction) * (-dt * 10.).exp();
}
@@ -69,11 +71,11 @@ impl MovementBase {
collide_player_tiles(self, map);
}
- pub fn movement_packet(&self, direction: Vec2, player: PlayerID) -> PacketS {
+ pub fn movement_packet(&self, player: PlayerID) -> PacketS {
PacketS::Movement {
pos: Some(self.position),
boosting: self.boosting,
- direction,
+ direction: self.direction,
player,
}
}