Welcome to Lecture One
What is this course going to teach you?
- How to make games with python. Libraries we are going to use include:
- pygame,
- pyopengl.
Who is teaching the course.
- This course is being done by two people. Geoff Howland and Rene Dudfield.
Introduction to python.
Why python for games?
- Pythons benefits include clear syntax, fast development, available on multiple platforms, quality free implementations, and open source code. Clear syntax is useful so you can understand what things do, so you can change things quickly. Python allows doesn't require many of the things which other computer languages do. Eg you do not need to type ';' at the end of every line. You do not need brackets for many things. The authors of python try very hard to make sure that python code written remains clear and understandable. Fast development with python is achieved by a few things. No compile times, lower amounts of typing you need to do. You don't need a lengthy compile before you can see your changes. There are even ways where you can change the program whilst it is running! This allows you to tweak your game quicker than compiled languages will allow.
An open source implementation is pretty important too. The executable to big? Remove parts of python. Recompile it in ways which make your particular game faster. Make all sorts of changes. You don't have too do these things. But if you need to, it's good to have the option.
Python, and python gaming websites.
There's a few websites you should explore, to gain true mastery of the python game programming way
Although we will be teaching python as we go, you may want to check out some other tutorials. If you don't know python allready, you should work through one of these other python tutorials over the next two weeks. If python is your first programming language, this is an excellent tutorial to follow: This tutorial is a quick introduction, for those who want to dive right in. Here's a big list of tutorials at the main python website. Some gaming websites you should check out include:
Of particular interest to new games programmers may be the game dictionary. If you come accross any words you don't know there might be the best place to look first for an explanation.
Installing your python programming environment.
- Time to get into the programming.
Windows installation.
- Go grab these files now! Install them in the order listed.
http://www.pygame.org/ftp/pygame-1.7.1release.win32-py2.4.exe
http://www.pygame.org/ftp/pygame-1.7.1release.zip This has an examples directory in it.
http://rene.f0o.com/~rene/stuff/examples.zip Or you can get the examples directly from this zip.
Note, these are the latest as of 2006-06-06. You may want to check http://www.python.org/ and http://www.pygame.org/
Linux/debian installation.
- apt-get install python pygame
Test your python installation.
- Run python. In windows, go to the start bar find python, and select the IDLE(Python GUI) option. In linux, type python at the command line.
Now you should see a prompt like >>> This is the interactive interpreter, you'll be able to type into here python code, and see it run. Fun. Now type in:
import pygame print dir(pygame) print dir()
That should print a bunch of stuff. The import command tells python to load that module. The print command is used to print stuff. duh. The dir command is really cool. It shows you what stuff is inside the pygame module. Now type:help(pygame.Rect)
That shows you documentation on a particular object/function/ variable. Try out help on a few other things inside of the pygame module. eg help(pygame.sprite) Check out the documentation for python, and pygame at these places.
Documentation for pygame: http://pygame.org/docs/index.html
Documentation for python: http://python.org/docs/
Running the chimp
- From the windows command prompt:
set PATH=%PATH%;c:\Python24\ cd "\Program Files\Pygame-Docs\examples" python chimp.py
Note, the examples directory might be somewhere else. Depending on where you unzipped it to. You may want to put the set line in your autoexec.bat so that you don't need to type it in every time you run python from the command line. In debian linux you do something similar:cd /usr/share/doc/python2.4-pygame/examples/ python chimp.py
Now try running some of the other examples in that directory.
Next
If you enjoyed this lecture, please consider leaving a tip.