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