import pygame, sys from pygame.locals import * pygame.init() DISPLAYSURF = pygame.display.set_mode((400, 300)) background = pygame.Surface((400, 300)) surface = pygame.Surface((10, 10)) surface.fill((0, 255, 0)) pos = [175, 125] pygame.display.set_caption("Hello, World!") while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_RIGHT: pos[0] += 20 DISPLAYSURF.blit(background, (0, 0)) DISPLAYSURF.blit(surface, pos) pygame.display.update()