From cee344c1213772ba06711fdbfaf62dd29ce3db56 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Fri, 19 May 2023 00:18:34 +0200 Subject: [PATCH] Move item collision handling into event handler This prevents item being picked without any move. Without this change, it was sufficient to place the player within boxarea and just wait for new boxes to arrive. --- src/main.rs | 2 -- src/world.rs | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 55583e7..7ff571d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,8 +61,6 @@ fn main() { world.update_box_areas(); } - world.handle_collisions(); - world.render(&mut canvas, &texture, &font); ::std::thread::sleep(Duration::from_millis(25)); diff --git a/src/world.rs b/src/world.rs index d68bd9d..3ec01b0 100644 --- a/src/world.rs +++ b/src/world.rs @@ -112,6 +112,8 @@ impl World { Event::KeyUp { .. } => self.execute_command(Command::StopPlayer(player_id)), _ => {} } + + self.handle_item_collisions(); } fn if_collides_execute(&mut self, commands: Vec) { @@ -187,7 +189,7 @@ impl World { } /// Handles both, collisions with lounge and any box area - pub fn handle_collisions(&mut self) { + pub fn handle_item_collisions(&mut self) { self.handle_lounge_collisions(); self.handle_boxarea_collisions(); }