Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- import os
- pygame.init()
- WIDTH, HEIGHT = 900, 500
- WIN = pygame.display.set_mode((WIDTH, HEIGHT))
- pygame.display.set_caption("TamaGo-tchi")
- FPS = 30
- WHITE = (255, 255, 255)
- RED = (255, 0, 0)
- YELLOW = (255, 255, 0)
- GREEN = (178, 255, 102)
- tama1width, tama1height = 55, 40
- def draw_window(yellow, hunger):
- health = 0
- if hunger >= 250:
- health = GREEN
- elif hunger >= 100 & hunger <249:
- health = YELLOW
- elif hunger <99:
- health = RED
- color = health
- print(hunger)
- WIN.fill((WHITE))
- BORDER = pygame.Rect(WIDTH / 2 - 5, 0, 10, hunger)
- pygame.draw.rect(WIN, health, BORDER)
- pygame.display.update()
- # press F to feed
- def main():
- hunger = 500
- clock = pygame.time.Clock()
- run = True
- while run:
- clock.tick(FPS)
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- run = False
- yellow = pygame.Rect(100, 300, tama1width, tama1height)
- hunger -= 1
- keys_pressed = pygame.key.get_pressed()
- if keys_pressed[pygame.K_f]:
- hunger += 4
- draw_window(yellow,hunger)
- pygame.quit()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement