# Homework 33, problem 3: arrow mover. # # A circle starts at the centre. Arrow keys move it continuously # (get_pressed). Pressing Escape quits the program. Print "moved" to the # terminal each frame the circle is moving. # # Run with: python exercises/33/homework/03-arrow-mover.py import pygame pygame.init() screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption("Arrow Mover") clock = pygame.time.Clock() cx, cy = 400, 300 speed = 4 running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # TODO: on KEYDOWN with K_ESCAPE, stop the loop # TODO: move the circle with get_pressed and print "moved" while it moves screen.fill((30, 30, 30)) pygame.draw.circle(screen, (255, 100, 100), (cx, cy), 30) pygame.display.flip() clock.tick(60) pygame.quit()