Pygame Short Notes
Pygame Short Notes
Event Handling
- Events check what the player is doing, like pressing keys or clicking.
- pygame.event.get() gets all events happening in the game.
- Example: If the player presses ESC, the game can quit!
pygame.init()
- This starts Pygame so we can use all its cool features.
- Without pygame.init(), nothing in Pygame will work!
- It must be called at the beginning of every game.
Game Loop
- The game loop keeps the game running. It runs forever until you quit.
- It checks inputs, updates the game, and redraws everything.
- Without a loop, the game would stop instantly!
Process Input
- This checks what the player is doing, like pressing keys or moving the mouse.
- Example: If K_LEFT is pressed, the character moves left.
- Without input, the game would just sit there doing nothing!
Drawing / Render
- This is how we draw things on the screen, like characters and backgrounds.
- We first clear the screen, then draw everything again.
- pygame.display.update() makes sure the new drawings appear!
Update
- This is where things change, like a character moving or a score increasing.
- Example: x += speed moves a player forward.
- Without updates, nothing in the game would move!