Programming 1
Week 11: Notes

Some of this week's topics are covered in Introducing Python:

For learning pygame, I highly recommend the book Making Games with Python & Pygame. You can read it online, or download a PDF copy for free.

Don't forget that we have a pygame quick reference page that is also linked from the course home page.

Here are the pygame examples we saw in the lecture:

hello.py
Draws a red circle on a black background.

count.py
Draws a circle whose color changes randomly each time you click the mouse. Also displays the click count in the center of the circle.

cat.py, cat.png
Draws a cat that moves around the window.

bounce.py
Displays a bouncing ball that settles to the ground and then mysteriously sinks into the Earth.

multibounce.py
Displays multiple bouncing balls. A new ball is created each time you click the mouse.

In the tutorial, we saw solutions to two exercises:

random_lines.py
Display 1000 random lines, each of the same length and with a random color

solar.py
Display an animation of the Solar System.
Here is a larger pygame example:
tic_tac_toe.py
The game of tic-tac-toe.