Programming Python

Hello everyone!

…and sorry for not posting anything in the last few weeks. Instead, I am going to make few blog posts this week.

So, straight to the topic. I have received a nice summer trainee position from my university. I will be working on something called Cyber Foraging (you can check more about this by googling). I will get back to this later, once I have started the work and studied this area more. My job is to program something using Python. I have done few projects with python, but not for almost a year, so I decided it is time to recap some of my skills (and learn more, of course!). Those of you who are not familiar with Python I recommend you reading the website and getting to know the language. It is fast, efficient and powerful (although the whitespace system sometimes gives some headaches).

As I have probably mentioned before I am very much interested in game programming, but haven’t had much luck with it (I have tried to start with a WAY TOO HARD approach). I have had some hard time getting Ogre3D to work with c++ ( I really don’t know why it doesn’t work correctly plus I haven’t had much time). Well, Now with my new Python interest, I found out that ogre has also python version of it. I was able to get this Python-Ogre running. YAY! However, making 3D games takes a lot of time, which I don’t have too much, I decided that I need something a little bit less complicated.  What I found out was this: PyGame.

Huh? PyGame? What’s that?

PyGame is a Python extension library that wraps SDL library and it’s helpers” SDL (short for Simple DirectMedia Layer) is cross-platform multimedia library that provides a low level access to audio, keyboard, mouse, joystic and 3D hardware.  SDL is written in C, but with the PyGame it will work with Python language as well. PyGame is actually really easy to program and even a programmer with not much programming experience can pretty quickly start coding nice 2D games. Why 2D? Simply put, 3D games require a lot more time, even more experience and more graphical skills than a 2D game (at least usually).  A nice introduction to PyGame can be read from here.

How to get started?

1. Download Python. I am using version 2.6.5 which is currently the newest (of the 2. series). A note here. Python has also 3.version, but the syntax is different from the more widely used 2. version. It also has more third party software available than 3. version.

2. Download PyGame. Here it is important that you download the same version as your Python is.

3. If you don’t want to use IDLE (the editor that comes with the Python). The problem with IDLE is, that it has no code-completion or other “little-more-sophisticated” functions. However, you can finely debug and program with IDLE. I recommed installing Eclipse (the classic version is good one) and the Python add-on for Eclipse.

The PyGame website actually has pretty good collection of Tutorials. I really recommend checking them out! I myself started going through them last week and I have a
lready programmed some nice and simple games (for example the classic Worm game). From my experience I recommend at least the following tutorials by Lorenzo E Danielsson. Also another one worth checking out can be found from Eli Bendersky’s website.

Here is a screenshot of a simple worm game I created accoring to Lorenzo’s tutorials

The links I have supplied in this blog entry:

Lappeenranta University of Technology –
Cyber Foraging by Google search –
Python –
Ogre3D –
Python-Ogre –
PyGame –
PyGame Introduction –
Download Python –
Download PyGame –
Download Eclipse –
Python add-on for eclipse –
PyGame Tutorials –
Lorenzo’s Worm game tutorial –
Eli Bendersky’s PyGame tutorials –


2 thoughts on “Programming Python

  1. Nice post.Wish you the best on your new trainee job; and hope you get enough time to really hack Python.

    I’ve been a Python developer myself for about 3 years and love it to bits 🙂

    Good luck.

  2. Pingback: Using Emergent Behavior in Video Games « Japskua's Programming Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s