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.
This commit is contained in:
Paul-Christian Volkmer 2023-05-19 00:18:34 +02:00
parent d23dfb969b
commit cee344c121
2 changed files with 3 additions and 3 deletions

View File

@ -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));

View File

@ -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<Command>) {
@ -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();
}