SaveText.Ru

Без имени
  1. import pygame
  2. import sys
  3.  
  4. DISPLAY_WIDTH = 500
  5. DISPLAY_HEIGHT = 500
  6. COLOR_GREEN = (128, 128, 0)
  7. PLAYER_HEIGHT = 30
  8. PLAYER_WIDTH = 100
  9. BALL_SIZE = 30
  10. Display = pygame.display.set_mode((500, 500))
  11.  
  12. def finish():
  13.     pygame.quit()
  14.     sys.exit(0)
  15.  
  16. clock = pygame.time.Clock()
  17. def main ():
  18.     player = pygame.Rect(DISPLAY_WIDTH / 2 - PLAYER_WIDTH / 2, DISPLAY_HEIGHT - 40, PLAYER_WIDTH, PLAYER_HEIGHT)
  19.     ball = pygame.Rect(DISPLAY_WIDTH / 2-BALL_SIZE / 2, DISPLAY_HEIGHT / 2, 30, 30)
  20.     supersell = pygame.Rect(DISPLAY_WIDTH / 2-PLAYER_WIDTH / 2, 40, PLAYER_WIDTH, PLAYER_HEIGHT)
  21.     while True:
  22.         for event in pygame.event.get():
  23.             if event.type == pygame.QUIT:
  24.                 finish()
  25.         Display.fill(COLOR_GREEN)
  26.         pygame.draw.rect(Display, (102, 0, 102), player)
  27.         pygame.draw.rect(Display, (255, 0, 0), ball)
  28.         pygame.draw.rect(Display, (51, 0, 255), supersell)
  29.         # draw rect
  30.         pygame.display.update()
  31.         clock.tick(25)
  32.  
  33. main()

Share with your friends:

Print