El Paso Pygamers — wiki
El Paso Pygamers is for anyone in the El Paso area who wants to program video games. We will use the Python programming langauge with Pygame. (See ElPasoWhy.) These are serious programming tools that will let you build real games from scratch.
Download¶
For Microsoft Windows, please download and install Python 3.1.4 and Pygame 1.9.1. There is no Pygame for Python 3 on the Mac, so we won't support the Mac until there is. And if you use Unix, I assume you can figure it all out for yourself.
Tutorials¶
Since there are plenty of great free Python tutorials available, there is no need to create a new one here. Below is a list of them. Look them over and read whichever one you like.
- Computer Science With Python and Pygame
- Invent Your Own Computer Games with Python
- Computer Science Circles
- How to Think Like a Computer Scientist
- Non-Programmer's Tutorial for Python 3
- The Python Tutorial
Note that we use Python 3, so you should read a tutorial for Python 3 not Python 2. All of the above tutorials are for Python 3.
Samples¶
Please download pygamers.zip. This has the sample code that we will use. It has the following structure:
- basics - This folder contains basic python programs to introduce you to what python can do.
- draw - This folder contains a number of python programs that draw things.
- drawing.py - This module makes drawing easier. The other programs in this folder use this module.
- drawing.html - This contains pydoc generated documentation of the drawing module.
- game - This folder contains a few simple games.
- gaming.py - This module is a very simple framework for Pygame that makes games a little easier to write.
- gaming.html - This contains pydoc generated documentation of the gaming module.
Start with the basics folder. With the help of the tutorials, you should be able to understand what each file in this folder does. Look at the python files and run them and make sure that you understand the output. Feel free to edit these files. Playing with programs is what programming is all about. One of the files is a guess-the-number game. Copy it to another python file and try to change it to limit the number of guesses.
Next look at the programs in the draw folder. To understand these programs, you should look at the documentation in drawing.html. These programs draw a few different things including some national flags. Try to write programs to draw other shapes, maybe other flags. When you have mastered this, then look at drawing.py together with the Pygame documentation and make sure you understand how it works.
Now you are ready for the game folder. The games here use the gaming module, so look at gaming.html and gaming.py to understand how this module works. Then look through the games. When you understand the games in this module, you can try to write your own games.
Note that both the drawing module and the gaming module let you press the escape key to interrupt the program. Then you can use the python command line to inspect variables or do whatever you want. You can do run() from the command line to continue your program.
Programming¶
You become a programmer by playing with code (programs). If you aren't sure how something works, just play with it and try things until you understand it. You can edit any files in the samples. After all, you can always download the samples again and start over.
Most tutorials will suggest that you program using IDLE. This is a tool that helps you write and run python programs.
Another option for running programs is to set the PYTHONINSPECT environment variable. This will run the python command line after your program is done. You can edit your python programs with your favorite text editor and then run the programs directly.
Getting Help¶
We have an El Paso Pygamers forum where you can post questions. There is also general Pygame info.
We have weekly classes at St. Nicholas Church on Thursdays from 1pm to 3pm in the building behind the church. Please bring your laptop.