# Homework 31, challenge: shrinking window. # # The window starts at 500x500. Each time the user presses the spacebar, # reduce the size by 50 pixels in both dimensions, down to a minimum of # 100x100. Use pygame.KEYDOWN and event.key == pygame.K_SPACE to detect # the key press, and pygame.display.set_mode(...) to resize. # # Run with: python exercises/31/homework/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 # TODO: on KEYDOWN with K_SPACE, shrink width and height and call set_mode screen.fill((50, 50, 50)) pygame.display.flip() clock.tick(60) pygame.quit()