import pygame
import sys
FPS = 60
WIDTH = 800
HEIGHT = 600
WHITE = (255, 255, 255)
ORANGE = (255, 150, 100)
clock = pygame.time.Clock()
sc = pygame.display.set_mode((WIDTH,HEIGHT))
x = WIDTH/2
y = HEIGHT/2
state = 10
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
x -= 3
if event.key == pygame.K_DOWN:
y += 3
if event.key == pygame.K_UP:
y -= 3
if event.key == pygame.K_RIGHT:
x += 3
if event.key == pygame.K_RETURN:
if state == 10:
state=50
else:
state = 10
sc.fill(WHITE)
if state == 10:
pygame.draw.circle(sc, ORANGE, (x, y), 50)
if state == 50:
pygame.draw.rect(sc, (255, 0, 255), (x,y, 50, 50))
pygame.display.update()
clock.tick(FPS)
|