12345678910111213141516171819202122232425262728293031323334353637 |
- import pygame
- from pygame.locals import (
- K_UP,
- K_DOWN,
- K_LEFT,
- K_RIGHT,
- K_ESCAPE,
- KEYDOWN,
- QUIT,
- )
- pygame.init()
- SCREEN_WIDTH = 800
- SCREEN_HEIGHT = 600
- screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
- running = True
- while running:
- for event in pygame.event.get():
- if event.type == KEYDOWN:
- if event.key == K_ESCAPE:
- running = False
- elif event.type == QUIT:
- running = False
- screen.fill((0, 80, 0))
- BLACK = (0, 0, 0)
- RED = (255, 0, 0)
- GREEN = (0, 160, 0)
- # pygame.draw.ellipse(screen, RED, (50, 20, 160, 100))
- pygame.draw.rect(screen, BLACK, (100, 100, 40, 40))
- pygame.draw.rect(screen, GREEN, (110, 110, 20, 20))
- pygame.display.update()
|