aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--light-client/assets/misc.ini1
-rw-r--r--light-client/assets/textures/solid.ta1
-rw-r--r--light-client/src/game.rs13
-rw-r--r--server/protocol/src/movement.rs4
4 files changed, 19 insertions, 0 deletions
diff --git a/light-client/assets/misc.ini b/light-client/assets/misc.ini
index 07052b90..eb79e7e1 100644
--- a/light-client/assets/misc.ini
+++ b/light-client/assets/misc.ini
@@ -1,2 +1,3 @@
player=player
+solid=solid
diff --git a/light-client/assets/textures/solid.ta b/light-client/assets/textures/solid.ta
new file mode 100644
index 00000000..78981922
--- /dev/null
+++ b/light-client/assets/textures/solid.ta
@@ -0,0 +1 @@
+a
diff --git a/light-client/src/game.rs b/light-client/src/game.rs
index 2692e6fc..231f6bd1 100644
--- a/light-client/src/game.rs
+++ b/light-client/src/game.rs
@@ -42,6 +42,7 @@ pub struct Game {
misc_textures: MiscTextures,
item_sprites: Vec<Sprite>,
movement_send_cooldown: f32,
+ interacting: bool,
}
pub struct Tile {
@@ -71,6 +72,7 @@ impl Game {
movement_send_cooldown: 0.,
misc_textures: MiscTextures::init(renderer),
item_sprites: Vec::new(),
+ interacting: false,
}
}
@@ -217,6 +219,17 @@ impl Game {
self.movement_send_cooldown += 0.04
}
+ if interact != self.interacting {
+ if interact {
+ packet_out.push_back(PacketS::Interact {
+ pos: Some(self.players[&self.my_id].movement.get_interact_target()),
+ });
+ } else {
+ packet_out.push_back(PacketS::Interact { pos: None });
+ }
+ self.interacting = interact;
+ }
+
for (pid, player) in &mut self.players {
if *pid == self.my_id {
let movement_packet =
diff --git a/server/protocol/src/movement.rs b/server/protocol/src/movement.rs
index 486da816..5a96155f 100644
--- a/server/protocol/src/movement.rs
+++ b/server/protocol/src/movement.rs
@@ -81,6 +81,10 @@ impl MovementBase {
rot: self.rotation,
}
}
+
+ pub fn get_interact_target(&self) -> IVec2 {
+ (self.position + Vec2::new(self.rotation.sin(), self.rotation.cos())).as_ivec2()
+ }
}
pub fn collide_player(p: &mut MovementBase, map: &HashSet<IVec2>) {