Wednesday, August 04, 2010

[Py] Install pygame-1.9.1 in Ubuntu (with running a game: Cave Copter)

I went to pygame's website to see whether there are some very simple examples for me to begin with. After several trials, I found the pygame version of Ubuntu 8.04 was 1.7 and it was too old to run some games, so I decided to install pygame from the source.

Things were almost easy. Just download and extract the source files and run the setup.py. Some error messages showed up:
sh: sdl-config: not found
sh: smpeg-config: not found


It means you need to install the following libraries.
$ sudo apt-get install libsdl-dev libsmpeg-dev

Ran the setup.py again and I got other warning messages as follows.
FONT : not found
IMAGE : not found
MIXER : not found
PNG : not found
JPEG : not found
PORTMIDI: not found
PORTTIME: not found

What I installed were:
libjpeg-dev libpng12-dev libportmidi-dev libsdl-ttf2.0-dev libsdl-image1.2-dev libsdl-mixer1.2-dev

Finally, ran
$ sudo python setup.py
and got new version pygame work!

---
After installing pygame-1.9.1, I tried to test the game, Cave Copter.

Cave Copter is a game using pygame. To make it run properly in Ubuntu, there still some minor works to do.

First, we need to change all the double backslashes in the original CaveCopter.py to single slash. Second, we have to change the *.PNG to *.png so that these png files can be recognized.

Hope I will have time to play with and to learn something from the source code...