We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Game Loop

Video games are generally built using a game loop. The simplest game loop has 3 steps:

  1. Check for player inputs
  2. Update the game world
  3. Draw the game to the screen

To create a good user experience, these 3 steps need to happen many times per second.

Assignment

  1. from logger import log_state
    
  2. screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
    
      1. for event in pygame.event.get():
            pass
        
  3. uv run main.py
    
  4. for event in pygame.event.get():
        if event.type == pygame.QUIT:
            return
    

Run and submit the CLI tests.