MCS 275 Spring 2024
Emily Dumas
Reminders and announcements:
We worked on a new Python project and used it to study version control with git and GitHub.
The project itself (a minimal "game") was mostly ignored!
git init
or git clone URL
git pull
git status
(optional)git add file1
git add file2
git status
(optional)git commit
git push
If push
ever fails, do a pull
, follow instructions, then push
again.
Python package for making games.
Key features: graphics, sound, user input device support, game mechanics calculations (e.g. collision detection)
Best for 2D sprite-based applications — i.e. a bunch of small images moving around and/or changing
and many more
Based on Simple DirectMedia Layer (SDL), a library written in C to let programs access sound and graphics hardware in an efficient way, uniformly across various OS.
SDL is fast, widely used, and well-tested.
Provides practice with event-based programming, where the main job is to respond to events that arrive from an external source.
while True:
evt = wait_for_event()
if evt.type == "alpha":
handle_alpha(evt)
elif:
...
elif:
...
while True:
redraw_window()
for evt in event_queue:
handle(evt)
wait_for_redraw_time()
Prioritizes scheduled redraw to keep graphics responsive and smooth.
Surface
- A thing you can draw on (e.g. an image, the screen, ...)Rect
- A rectangular region in a surface (with lots of utility methods)Sprite
- A visible object that is part of the game (has a location, behavior, draw process)Let's analyze the hello world example from last time, then build it out to an actual game.