Optimise physic
This commit is contained in:
+5
-3
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user