- Welcome to Lecture One
- Introduction to python.
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:
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
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.
- Go grab these files now! Install them in the order listed.
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.
- 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/
Running the chimp
- From the windows command prompt:
set PATH=%PATH%;c:\Python24\ cd "\Program Files\Pygame-Docs\examples" python chimp.pyNote, 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.pyNow try running some of the other examples in that directory.
If you enjoyed this lecture, please consider leaving a tip.