summaryrefslogtreecommitdiff
path: root/server/protocol/src/movement.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-08-10 20:57:06 +0200
committermetamuffin <metamuffin@disroot.org>2024-08-10 20:57:06 +0200
commit7dbb34febaf75572f99fee459a77cf917de05d8f (patch)
tree72ba067aa5003d110f2bb707fb3e9c429388505b /server/protocol/src/movement.rs
parent3d13c85ec2e3acbee249b4baf20797cc38a8a121 (diff)
downloadhurrycurry-7dbb34febaf75572f99fee459a77cf917de05d8f.tar
hurrycurry-7dbb34febaf75572f99fee459a77cf917de05d8f.tar.bz2
hurrycurry-7dbb34febaf75572f99fee459a77cf917de05d8f.tar.zst
Change protocol and server to allow multiple players per connection (untested)
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,
}
}