import pygame import sys pygame.init() screen = pygame.display.set_mode((400, 300)) background = pygame.Surface((400, 300)) background.fill((0, 0, 0)) # Fill with black surface = pygame.Surface((50, 50)) surface.fill((0, 255, 0)) # Green square pos = [177, 125] clock = pygame.time.Clock() while True: events = pygame.event.get() for event in events: if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_RIGHT: pos[0] += 20 screen.blit(background, (0, 0)) screen.blit(surface, pos) pygame.display.update() clock.tick(60) # Add this to reduce CPU usage