Advertisement
Retroledeom

Untitled

May 20th, 2022
968
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. import pygame
  2. import os
  3.  
  4. pygame.init()
  5. WIDTH, HEIGHT = 900, 500
  6. WIN = pygame.display.set_mode((WIDTH, HEIGHT))
  7. pygame.display.set_caption("TamaGo-tchi")
  8.  
  9. FPS = 30
  10. WHITE = (255, 255, 255)
  11. RED = (255, 0, 0)
  12. YELLOW = (255, 255, 0)
  13. GREEN = (178, 255, 102)
  14. tama1width, tama1height = 55, 40
  15.  
  16.  
  17. def draw_window(yellow, hunger):
  18.     health = 0
  19.     if hunger >= 250:
  20.         health = GREEN
  21.     elif hunger >= 100 & hunger <249:
  22.         health = YELLOW
  23.     elif  hunger <99:
  24.         health = RED
  25.  
  26.     color = health
  27.     print(hunger)
  28.     WIN.fill((WHITE))
  29.     BORDER = pygame.Rect(WIDTH / 2 - 5, 0, 10, hunger)
  30.     pygame.draw.rect(WIN, health, BORDER)
  31.     pygame.display.update()
  32.  
  33. # press F to feed
  34. def main():
  35.     hunger = 500
  36.     clock = pygame.time.Clock()
  37.     run = True
  38.     while run:
  39.         clock.tick(FPS)
  40.         for event in pygame.event.get():
  41.             if event.type == pygame.QUIT:
  42.                 run = False
  43.         yellow = pygame.Rect(100, 300, tama1width, tama1height)
  44.         hunger -= 1
  45.         keys_pressed = pygame.key.get_pressed()
  46.         if keys_pressed[pygame.K_f]:
  47.             hunger += 4
  48.         draw_window(yellow,hunger)
  49.  
  50.     pygame.quit()
  51.  
  52.  
  53. if __name__ == '__main__':
  54.     main()
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement