If you already know a bit of programming and Python, and want to get up to speed on the Pygame 2D game framework, here’s a cheat sheet that you can look over. It implements a very short Pygame program covering most of Pygame’s basic features.
View the Pygame Cheat Sheet.
You can also download the Pygame program itself, along with the cat.png and bounce.wav files it uses. You will need to install Python and Pygame first to run this program. The program looks like this when you run it:
Pygcurse (pronounced “pig curse”) is a curses library emulator that runs on top of the Pygame framework. It provides an easy way to create text adventures, roguelikes, and console-style applications. The mascot of Pygcurse is a blue pig with a skull tattoo on its butt.
Download Pygcurse and Demo Programs.
Read the Pygcurse tutorial.
View the Pygcurse homepage.
Pygcurse provides several benefits over normal text-based stdio programs:
- Color text and background.
- The ability to move the cursor and print text anywhere in the console window.
- The ability to make console apps that make use of the mouse.
- The ability to have programs respond to individual key presses, instead of waiting for the user to type an entire string and press enter (as is the case with input()/raw_input()).
- The ability to use any font and any character in those fonts.
- Since the console window that Pygcurse uses is just a Pygame surface object, additional drawing and transformations can be applied to it. Multiple surfaces can also be used in the same program.
Pygcurse also provides some additional features that curses normally doesn’t, such as tinting, shadows, textboxes, and line drawing functions.
Pygcurse requires Pygame to be installed. Pygame can be downloaded from http://pygame.org. Pygcurse can be used with either Python 2 or Python 3.
The source code of everything in this article can be downloaded here: floodfill_src.zip
Consider the Lazy Zombie
This is a cat:
This is a normal human:
This is a normal human who has been turned into an ungodly, flesh-eating zombie of the undead:
Zombies are lazy and will only bite things that are next to them. Humans that are bitten will then turn into zombies:
There is an interesting recursive principle here, because the humans that have turned into zombies will start to bite other humans that are next to them, which will make more zombies, who bite more adjacent humans, which will make more zombies, and so on and so on in a chain reaction: