Skip to content
Snippets Groups Projects
Commit 67bd4e81 authored by Fabian Heinrich's avatar Fabian Heinrich
Browse files

removed unused return value

parent f0f3eb38
No related branches found
No related tags found
2 merge requests!110V1.2.0 changes,!104Resolve "Faster Drawing"
......@@ -107,25 +107,25 @@ class Movement:
def get_player_push(
self, player_positions: npt.NDArray[float]
) -> Tuple[npt.NDArray[bool], npt.NDArray[float]]:
) -> npt.NDArray[float]:
"""Calculates the collision and push vectors for each player.
Args:
player_positions (numpy.ndarray): An array of shape (n, 2) representing the positions of the players.
Returns:
tuple: A tuple containing two numpy arrays. The first array (collisions) is a boolean array of shape (n,) indicating
whether each player has collided with another player. The second array (push_vectors) is a numpy array of shape (2,)
Array (push_vectors) is a numpy array of shape (2,)
representing the total push vector for each player.
"""
distances_players_after_scipy = distance_matrix(
distances_players_after = distance_matrix(
player_positions, player_positions
)
collisions = distances_players_after < 2 * self.player_radius
player_diff_vecs = -(
player_positions[:, np.newaxis, :] - player_positions[np.newaxis, :, :]
)
collisions = distances_players_after_scipy < (2 * self.player_radius)
eye_idxs = np.eye(len(player_positions), len(player_positions), dtype=bool)
collisions[eye_idxs] = False
if np.any(collisions):
......@@ -135,8 +135,7 @@ class Movement:
)
player_diff_vecs[collisions == False] = 0
push_vectors = np.sum(player_diff_vecs, axis=0)
collisions = np.any(collisions, axis=1)
return collisions, push_vectors
return push_vectors
def perform_movement(
self,
......@@ -181,13 +180,13 @@ class Movement:
# Collisions player between player
force_factor = 1.2
_, push_vectors = self.get_player_push(targeted_positions)
push_vectors = self.get_player_push(targeted_positions)
updated_movement = (force_factor * push_vectors) + player_movement_vectors
new_targeted_positions = player_positions + (
updated_movement * (self.player_movement_speed * d_time)
)
# same again to prevent squeezing into other players
_, push_vectors2 = self.get_player_push(new_targeted_positions)
push_vectors2 = self.get_player_push(new_targeted_positions)
updated_movement = (force_factor * push_vectors2) + updated_movement
new_targeted_positions = player_positions + (
updated_movement * (self.player_movement_speed * d_time)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment