Advertisement
ItzSaf

Untitled

May 6th, 2025
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1.         # Draw stamina bar
  2.         stamina_bar_width = 100
  3.         stamina_bar_height = 10
  4.         stamina_x = 10
  5.         stamina_y = 90
  6.        
  7.         # Background bar (empty stamina)
  8.         pygame.draw.rect(surface, (100, 100, 100),
  9.                          (stamina_x, stamina_y, stamina_bar_width, stamina_bar_height))
  10.        
  11.         # Foreground bar (current stamina)
  12.         stamina_percent = self.stamina / self.max_stamina
  13.         current_bar_width = max(0, int(stamina_bar_width * stamina_percent))
  14.         pygame.draw.rect(surface, (0, 200, 0),
  15.                          (stamina_x, stamina_y, current_bar_width, stamina_bar_height))
  16.                          
  17.         # Draw recovery boost button
  18.         button_x = stamina_x + stamina_bar_width + 10
  19.         button_y = stamina_y
  20.         button_width = 20
  21.         button_height = stamina_bar_height
  22.        
  23.         # Button color changes when active
  24.         button_color = (200, 200, 0) if self.recovery_boost > 1.0 else (150, 150, 0)
  25.         pygame.draw.rect(surface, button_color,
  26.                          (button_x, button_y, button_width, button_height))
  27.                          
  28.         # Label for boost button
  29.         font = pygame.font.SysFont(None, 20)
  30.         button_text = font.render("R", True, BLACK)
  31.         text_rect = button_text.get_rect(center=(button_x + button_width // 2,
  32.                                                 button_y + button_height // 2))
  33.         surface.blit(button_text, text_rect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement