This commit is contained in:
Chanumask
2024-05-06 19:30:27 +02:00
parent 865669055d
commit 39b123221b
3 changed files with 54 additions and 55 deletions

View File

@ -237,13 +237,13 @@ class Renderer:
def render_action_icons(self, action_entities):
"""
Renders action icons based on the entities' specified actions, positions, and probabilities.
Renders action icons based on the entities' specified actions' name, position, rotation and probability.
Renders probabilities unequal 0.
:param action_entities: List of entities representing actions.
:type action_entities: List[RenderEntity]
"""
self.fill_bg() # Clear the background
self.fill_bg()
font = pygame.font.Font(None, 24) # Initialize the font once for all text rendering
for action_entity in action_entities:
@ -253,11 +253,11 @@ class Renderer:
# Load and potentially rotate the icon based on action name
img = self.assets[action_entity.name.lower()]
if img is None:
print(f"Error: No asset available for '{action_entity.name}'. Skipping rendering this entity.")
continue
if hasattr(action_entity, 'rotation'):
img = pygame.transform.rotate(img, action_entity.rotation)
if img is None:
print(f"Error: No asset available for '{action_entity.name}'. Skipping rendering this entity.")
continue
# Blit the icon image
img_rect = img.get_rect(center=(action_entity.pos[0] * self.cell_size + self.cell_size // 2,