Optimise physic

This commit is contained in:
2026-10-10 14:53:04 +02:00
parent d37214f1ed
commit 9030146ec8
+5 -3
View File
@@ -48,9 +48,11 @@ class Game:
self.gameState.add_move_count() self.gameState.add_move_count()
# Try to move the player according to his velocity # Try to move the player according to his velocity
block_at_velocity = self._get_block_at_velocity() velocity_position = self.get_position_at_velocity()
if not block_at_velocity or not block_at_velocity.solid: block_at_velocity = None
velocity_position = self.get_position_at_velocity() # TODO : optimize 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: if velocity_position:
self.gameState.set_player_position(velocity_position) self.gameState.set_player_position(velocity_position)
if block_at_velocity: if block_at_velocity: