From 9030146ec8fbee8497f18b4168bb8b3e2b2c6d3c Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Sat, 10 Oct 2026 14:53:04 +0200 Subject: [PATCH] Optimise physic --- game/game.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/game/game.py b/game/game.py index 3aaad59..78f067c 100644 --- a/game/game.py +++ b/game/game.py @@ -48,9 +48,11 @@ class Game: self.gameState.add_move_count() # Try to move the player according to his velocity - block_at_velocity = self._get_block_at_velocity() - if not block_at_velocity or not block_at_velocity.solid: - velocity_position = self.get_position_at_velocity() # TODO : optimize + velocity_position = self.get_position_at_velocity() + block_at_velocity = None + if velocity_position is not None: + block_at_velocity = self.map.get_block_at(velocity_position[0], velocity_position[1]) + if not block_at_velocity or not block_at_velocity.solid: # Empty space or non-solid block → Move the player to the new position if velocity_position: self.gameState.set_player_position(velocity_position) if block_at_velocity: