def main(): pygame.init() FPS = 30 # 30 frames per second fps_clock = pygame.time.Clock() # Code to create the initial window window_size = (800, 800) screen = pygame.display.set_mode(window_size) # set the title of the window pygame.display.set_caption("A House") #Set of Colors WHITE = pygame.Color(255, 255, 255) GOLD = pygame.Color(255, 215, 0) RED = pygame.Color(255, 0, 0) screen.fill(WHITE) colors_for_house = {'house': GOLD, 'roof': RED} house = House(200, 200, 200, colors_for_house) house.draw(screen) move_left = False; move_right = False; move_down = False; move_up = False; while True: # <--- main game loop for event in pygame.event.get(): if event.type == QUIT: # QUIT event to exit the game pygame.quit() sys.exit() ################################ if event.type == KEYDOWN: if event.key == K_UP: move_up = True if event.key == K_DOWN: move_down = True if event.key == K_LEFT: move_left = True if event.key == K_RIGHT: move_right = True if event.type == KEYUP: if event.key == K_UP: move_up = False if event.key == K_DOWN: move_down = False if event.key == K_LEFT: move_left = False if event.key == K_RIGHT: move_right = False ############################### if move_up: house.change_y(-5) if move_down: house.change_y(5) if move_left: house.change_x(-5) if move_right: house.change_x(5) screen.fill(WHITE) house.draw(screen) pygame.display.update() # Update the display when all events have been processed fps_clock.tick(FPS)