From 05a789d4cee0bfcb9b4cfa13c44dec4fc8fa924b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filips=20Kalni=C5=86=C5=A1?= Date: Mon, 16 Mar 2026 07:45:36 +0000 Subject: [PATCH] Update inventory.py --- inventory.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/inventory.py b/inventory.py index f5b4e28..f5053c4 100644 --- a/inventory.py +++ b/inventory.py @@ -53,14 +53,13 @@ class Inventory: start_x = self.x + self.padding start_y = self.y + 70 - # Convert slots to list for display items_list = list(self.slots.items()) - index = 0 mouse = pygame.mouse.get_pos() for row in range(self.grid_rows): for col in range(self.grid_cols): + cell_rect = pygame.Rect( start_x + col * (self.cell_size + self.cell_padding), start_y + row * (self.cell_size + self.cell_padding), @@ -85,21 +84,14 @@ class Inventory: ) pygame.draw.rect(screen, item.color, icon_rect) - # Draw amount - amount_text = font.render(str(amount), True, (255, 255, 255)) - screen.blit(amount_text, (cell_rect.x + 2, cell_rect.y + 2)) + # Draw amount if stack > 1 + if amount > 1: + amount_text = font.render(str(amount), True, (255, 255, 255)) + screen.blit(amount_text, (cell_rect.x + 2, cell_rect.y + 2)) - # Tooltip on hover + # Tooltip when hovering if cell_rect.collidepoint(mouse): tooltip = font.render(item.name, True, (255, 255, 0)) screen.blit(tooltip, (mouse[0] + 10, mouse[1] + 10)) - index += 1 - screen.blit(amount_text, (cell_rect.x + 2, cell_rect.y + 2)) - - # Tooltip on hover - if cell_rect.collidepoint(mouse): - tooltip = font.render(item.name, True, (255, 255, 0)) - screen.blit(tooltip, (mouse[0] + 10, mouse[1] + 10)) - - index += 1 + index += 1 \ No newline at end of file