# Homework 31 solution, challenge: shrinking window. # Run with: python exercises/31/homework/solutions/04-shrinking-window.py import pygame pygame.init() width = 500 height = 500 screen = pygame.display.set_mode((width, height)) pygame.display.set_caption("Shrinking Window") clock = pygame.time.Clock() running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: width = max(100, width - 50) height = max(100, height - 50) screen = pygame.display.set_mode((width, height)) screen.fill((50, 50, 50)) pygame.display.flip() clock.tick(60) pygame.quit()