qwirkle.py 816 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import pygame
  2. from pygame.locals import (
  3. K_UP,
  4. K_DOWN,
  5. K_LEFT,
  6. K_RIGHT,
  7. K_ESCAPE,
  8. KEYDOWN,
  9. QUIT,
  10. )
  11. pygame.init()
  12. SCREEN_WIDTH = 800
  13. SCREEN_HEIGHT = 600
  14. screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
  15. running = True
  16. while running:
  17. for event in pygame.event.get():
  18. if event.type == KEYDOWN:
  19. if event.key == K_ESCAPE:
  20. running = False
  21. elif event.type == QUIT:
  22. running = False
  23. screen.fill((0, 80, 0))
  24. BLACK = (0, 0, 0)
  25. RED = (255, 0, 0)
  26. GREEN = (0, 160, 0)
  27. # pygame.draw.ellipse(screen, RED, (50, 20, 160, 100))
  28. pygame.draw.rect(screen, BLACK, (100, 100, 40, 40))
  29. pygame.draw.rect(screen, GREEN, (110, 110, 20, 20))
  30. pygame.display.update()