📝 Worksheet← Lesson← Course
BitWithBite
Pygame Mastery · Quick Reference

Python Refresher Cheat Sheet

Pygame Mastery
In one line: Before Pygame ever enters the picture, this module locks in the core Python skills every future game leans on — variables, control flow, loops, functions, and object-oriented programming.

Key Ideas

1The Game Loop. Every game repeats three steps ~60 times a second: handle input, update state, render the frame. This while-loop shape is the foundation of every module ahead.
2Variables & Data Types. Python infers type from the value you assign: whole numbers are int, decimals float, text str, true/false bool. input() always returns a str.
3Control Flow. if/elif/else branch on conditions and can nest. Python 3.10's match/case cleanly branches on one value — perfect for game states like "menu" or "paused".
4Loops. while repeats until a condition changes (the game loop itself); for + range() repeats a fixed number of times; break exits early, continue skips an iteration.
5Functions & Scope. Functions take parameters and send results back with return. Variables made inside only exist inside (scope). Python also has lambda one-liners and recursion.
6OOP. class is a blueprint; __init__ is the constructor; methods act on self; inheritance lets one class extend another; polymorphism lets subclasses override behavior. This becomes every Sprite from Module 6 on.

Common Mistakes

Assuming input() gives you a number.
age = int(input("Age: ")) — convert manually, it's always a str
Writing if health = 0: instead of a comparison.
if health == 0: — = assigns, == compares
Forgetting a function needs an explicit return.
No return -> the function silently gives back None
Leaving self out of a method's parameters.
def attack(self): — self is always the first parameter
GameObjectPlayerEnemy
GameObject is the base class; Player and Enemy inherit its attributes and override methods via polymorphism.