This function must be called first before anything else in Pygame
What is pygame.init()?
In Pygame, this is the direction Y increases — opposite of math class
What is downward?
This is the Pygame function used to draw a filled circle
What is pygame.draw.circle()?
These are the 3 parts of the Pygame game loop in the correct order
What is Events → Update → Draw?
This is where you must save an image file for pygame.image.load("hero.png") to work
What is in the same folder as your Python script?
This is what pygame.display.set_caption("My Game") does
What is it sets the title of the game window?
This is the RGB value for pure white
What is (255, 255, 255)?
This is the correct argument order for pygame.draw.rect()
What is (surface, color, (x, y, width, height))?
This is what happens to movement if you remove clock.tick(60) from the game loop
What is the game runs at hundreds of FPS making movement feel jittery and uncontrollable?
This is what convert_alpha() does when loading a sprite image
What is it supports transparent backgrounds so PNG files with transparency display correctly?
This is what happens if you forget pygame.display.flip() at the end of your game loop
What is nothing appears on screen... the frame never gets shown?
This is where this coordinate sits on an 800x600 screen: (400, 300)
What is the exact center of the screen?
This is which shape appears on top when these two lines run in order:
pygame.draw.rect(screen, (255, 0, 0), (100, 100, 200, 200))
pygame.draw.circle(screen, (0, 0, 255), (200, 200), 80)
What is the blue circle? Shapes drawn later appear on top
This is what is missing from this game loop that causes the window to freeze immediately: (ignore indents)
while True:
screen.fill((0, 0, 0))
pygame.draw.circle(screen, (255, 0, 0), (400, 300), 50)
pygame.display.flip()
What is the event loop — for event in pygame.event.get()? Without it Pygame can't process the quit event and the OS thinks the program is frozen
This is what is wrong with this code and how it affects performance: (ignore indents)
while True:
hero_img = pygame.image.load("hero.png").convert_alpha()
screen.blit(hero_img, (player_x, player_y))
What is the image is loaded inside the game loop so it reloads from disk every single frame causing a massive slowdown — move it to BEFORE while True?
This is what this code does and what color the window will be: (two things)
screen = pygame.display.set_mode((800, 600)) screen.fill((255, 165, 0))
pygame.display.flip()
What is it creates an 800x600 window and fills it orange?
This is the color that (128, 0, 128) makes
What is purple?
This is what pygame.draw.polygon() needs that pygame.draw.rect() does not
What is a list of (x, y) points to connect instead of just a position, width, and height?
This is the difference between these two and which one gives smooth continuous movement:
# A
if event.type == pygame.KEYDOWN:
player_x -= SPEED
# B
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
player_x -= SPEED
What is Option B? Option A fires only ONCE when the key is first pressed — Option B checks every frame the key is held down giving smooth continuous movement
DAILY DOUBLE
A student runs this code and their hero moves BUT it leaves a trail of blue rectangles across the screen as it moves. This is the exact cause and the one line fix: (ignore indents)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit(); sys.exit()
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]: player_x -= SPEED
if keys[pygame.K_RIGHT]: player_x += SPEED
pygame.draw.rect(screen, (80, 140, 255),
(player_x, player_y, SIZE, SIZE))
pygame.display.flip()
clock.tick(60)
What is screen.fill() is missing at the start of the draw section? Without it the previous frame's rectangle stays on screen every frame leaving a trail — add screen.fill((30, 30, 50)) before the pygame.draw.rect() line
This is what is wrong with this Pygame setup:
import pygame
screen = pygame.display.set_mode((800, 600))
pygame.init()
What is pygame.init() must be called BEFORE pygame.display.set_mode() — the order is wrong?
A student wants to draw something in the bottom right corner of an 800x600 screen. They use (800, 600) as the position but nothing appears. This is why
What is (800, 600) is outside the screen? In Pygame (0,0) is top left so the bottom right corner is actually just inside the edges — they need to subtract the size of their shape
DAILY DOUBLE
A student runs this code and sees nothing but a black screen even though they drew shapes. This is EXACTLY why: (ignore the indents)
while True:
pygame.draw.rect(screen, (255, 0, 0), (100, 100, 200, 200))
screen.fill((0, 0, 0))
pygame.display.flip()
What is screen.fill() is called AFTER the shapes are drawn so it paints over everything — always fill the background FIRST then draw shapes on top?
A student's player moves fine but leaves a trail of rectangles across the screen as it moves. This is the cause and the fix
What is forgetting screen.fill() at the START of the game loop? Without it the previous frame's drawings stay on screen — always fill the background first before drawing anything
A student has clamping working perfectly at SPEED=5 but when they change to SPEED=50 the player clips through the boundaries. This is the exact reason why
What is at SPEED=50 the player moves 50 pixels per frame — if the player is at x=760 on an 800 wide screen with SIZE=50, one frame later it's at x=810 which is past the boundary before clamping can bring it back?