From e43289341eeeae0f775fecf1a97c49a29bc0edff Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 25 Jul 2024 12:07:27 +0200 Subject: pc: player collisions --- pixel-client/src/game.rs | 11 +++++++++++ pixel-client/src/main.rs | 1 + 2 files changed, 12 insertions(+) (limited to 'pixel-client/src') diff --git a/pixel-client/src/game.rs b/pixel-client/src/game.rs index 13ed1709..cc1645d9 100644 --- a/pixel-client/src/game.rs +++ b/pixel-client/src/game.rs @@ -155,6 +155,7 @@ impl Game { let movement_packet = player .movement .update(&self.collision_map, direction, boost, dt); + if send_movement { self.network.queue_out.push_back(movement_packet); } @@ -167,6 +168,16 @@ impl Game { self.camera_center.exp_to(player.movement.position, dt * 5.); } + for p1 in &self.player_ids { + for p2 in &self.player_ids { + if p1 != p2 { + if let Some([p1, p2]) = self.players.get_many_mut([p1, p2]) { + p1.movement.collide(&mut p2.movement, dt); + } + } + } + } + for player in self.players.values_mut() { if let Some(item) = &mut player.item { item.parent_position = player.movement.position; diff --git a/pixel-client/src/main.rs b/pixel-client/src/main.rs index 0ebe7b44..8c140fc5 100644 --- a/pixel-client/src/main.rs +++ b/pixel-client/src/main.rs @@ -15,6 +15,7 @@ along with this program. If not, see . */ +#![feature(map_many_mut)] use clap::{Parser, Subcommand}; use game::Game; use hurrycurry_protocol::glam::Vec2; -- cgit v1.2.3-70-g09d2