Update inventory.py
parent
5be699c21e
commit
05a789d4ce
22
inventory.py
22
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
|
||||
Loading…
Reference in New Issue