May 7th, 2008
Mark Mruss
Note: This article was first published the October 2007 issue of Python Magazine
XML is everywhere. It seems you can’t do much these days unless you utilize XML in one way or another. Fortunately, Python developers have a new tool in our standard arsenal: the ElementTree module. This article aims to introduce you to reading, writing, saving, and loading XML using the ElementTree module.
- Introduction
- Reading XML data
- Listing 1
- Listing 2
- Reading XML Attributes
- Writing XML
- Listing 3
- Writing XML Attributes
- Reading XML Files
- Writing XML Data to a File
- Reading from the Web
- Conclusion
Read the rest of this entry »
Popularity: 6%
Posted in Uncategorized, python, tutorial, xml | 3 Comments »
April 1st, 2008
So I had some free time since I last posted so I hacked a little bit more into my simple game editor. I’ve a few things in there that I wanted to get in:
- A grid
- A paint mode to easily add sprites
- An erase mode so that sprites can be removed
- Fully (or so it seems) working property addition to the sprites
- Added some organization to the code. I was hacking on this enough that putting things in their right spot started to make more and more sense.
- Started to use mercurial to keep track of source changes. I know how important version control is, and after making a silly mistake I decided that I wanted to start using it with this project.
You can take a look at how things are working here:

![]()
It’s not pretty yet, but it’s coming along.
Popularity: 6%
Posted in Uncategorized, python, game engine | 10 Comments »
March 22nd, 2008
Hey Everyone,
Sorry I’ve been away for a bit, work and trips and writing for Python Magazine had me pretty busy and I wasn’t able to reply to everyone’s comments on the simple Python game engine. I really do appreciate the comments though so please keep them coming.
I have been thinking about the simple game engine quite a bit though and wondering where to start on it all, and whether or not it makes sense to start on it at all! After some thinking I decided that what I would want most (for a variety of reasons) would be an easy to use level editor. So with a day off from work and life yesterday I started to do some hacking with PyGTK and pyglet to see if I couldn’t get a simple level editor going.
The results are still quite crude, but the basics are starting to get in there:

![]()
As you can see it’s a PyGTK application with an OpenGL window that displays pyglet sprites. There is a properties list, where you can add and edit properties or the sprite. There is also a “content” list that displays all of the graphics in your project’s “content” directory. Then you can add any of those images to your level. You can also select sprites and move them around, or edit their properties (notice the monster with the yellow border around it?).
The idea is that eventually this will save the information out into a human readable file type (yaml, xml, whatever) that games (your game?) will then read in for their levels. The properties will be saved with each sprite and then applied when you load the level. That way you can add specific properties to specific sprites.
This is still very much a work in progress, but when it gets a little bit more stable and if people are interested I think I’ll create a project on sourceforge or google code so the other people can start working with it or hacking it.
So…ideas? Comments? Thoughts?
Popularity: 7%
Posted in Uncategorized, python, PyGlet, game engine | 4 Comments »
February 24th, 2008
After my last post and receiving a few helpful responses I thought I would make a post outlining some of my thoughts and ideas on what I meant and what I envision the game engine would do. Please note that these are simply some more rough ideas and brainstorming, it’s not meant to be exhaustive or to appear to be too thought out.
What I would like to see in this magical engine (in no particular order):
- Level Editor/Sprite Editor - I think that this is really important. If the goal is to make creating 2d games very quickly and easily an editor is a must in my opinion. I see this as being the place where you can both position level items as well as perform some scripting. The question is whether this should be written using the actual engine, or with another toolkit?
- Widgets - I would like to see some sort of a widget toolkit. Here’s where engines start to get large and I start to get worried. But I think that this is important, especially if the level editor were to be written in the engine itself. This would allow people to use menus, scrollbars, buttons, checkboxes, radiobuttons, and so on. This would also have to be theme-able, so that people could easily change the look and feel of their games.
- Physics - Some sort of physics engine, probably use an existing technology, or a very simple implementation written in pure python.
- Easy distribution for the final product - I also see this as being important. It has to be easy for people to wrap up their finished product and distribute it.
- Cross-platform - Goes without saying.
- Component based - Not sure about this one, but I really like the theory behind it. This would mean that the engine itself would be made up of components. Components that could be intermingled and switch. So one component would be the physics engine, and if someone wanted to use a different physics engine they would simply swap out the old physics engine with the new one. This would also (hopefully) work with with the idea of having say a side scrolling engine, and a isometric engine, these would simply be different components in the over all engine. Is this possible? I’m not sure.
- Easy to use - Very important, it should be easy for new users to work with, but also allow for more experienced users to make complex and complicated games. Meaning that it shouldn’t stand in peoples way.
- Standard human-readable level/file type - Be this xml, lxml, yaml, ini files or whatever. This would allow people to create other level editors, or design levels without the actual level editor.
So those are some ideas that I have, some from other “engines” that I have started in the past, and some just from thinking about it. When I go back and re-read the list I start to get the feeling that maybe it’s too ambitious. I mean a widget toolkit that is theme-able? That’s a lot to do. But that could also be something that is done at a later date. The engine does not need to be done in the actual editor. It could be done in a toolkit like PyGTK or PyQT4 to start and then an additional editor could be added on later.
Of course real life and time always play a role in completing anything as large as this…so who knows maybe I’m simply talking aloud, or maybe this is something that would help the Python game community? Just thinking….
Popularity: 10%
Posted in python, game engine | 20 Comments »
February 21st, 2008
Is there anyone else out there that is looking for this? A simple Python (2D) game engine? I’m not talking about something like PyGame, PyGlet, or Rabbyt, all of which are very good at what they do. What I’m talking about may use these technologies (I’m thinking PyGlet and Rabbyt) but would do so in a way to create an actual “game engine”.
This is something that I have tried to do many times in the past, and I’ve always gotten stuck on the idea of trying to make it very very flexible, so that you could use whichever technology with the engine that you wanted to. But lately I’ve been thinking of a different approach. What about a very specific engine? Something that is very geared to performing one task well. Lets say a 2D scrolling engine. Something with a set level format, easy save and load, a screen system, and maybe some widgets.
Basically I’m thinking of something that will let people who are interested in creating simple games do so very easily. Something that isn’t that doesn’t necessarily do everything, but if you follow some simply steps you can get a “game” going very quickly.
Anyone else interested in something like this? Anyone else interested in working with me on something like this? Or perhaps you have information on a technology that is already there? Or maybe you have information on simple game engine design? I’ve feeling the itch to create some games again using Python, but I havn’t yet found the tool to scratch that itch…maybe the solution is to create on? If you are interested, or have some information, drop me a comment or shoot me an email.
mark…signing off after a long day on the computer not programming Python or video games, and definitely not doing it for himself.
Popularity: 11%
Posted in News, python | 8 Comments »
February 13th, 2008
I’d like to thank everyone that commented on my last post, and everyone that has emailed me ideas. They are all very much appreciated. It’s hard keeping up with everything that is happening in the Python world, and sometimes the coolest things are happening in far off places.
I got a few suggestions for Pycairo, which is something that I have considered in the past, but I’ve found it a little bit difficult and time consuming do to the lack of Python specific documentation.
The MDP toolbox also looks pretty cool, I just have no idea what I could possibly do with it!
If anyone else has anymore ideas please let me have them. Anything graphical, non-graphical, game related, swarm theory, random generation, AI, a Rorschach test creator…anything! I’m collecting ideas for this blog and my monthly column so anything that would also really interest new Python programmers would be a huge plus.
Take care and get ready for 3000!
Popularity: 12%
Posted in News, python | 5 Comments »
January 24th, 2008
No I’m not dead…even after the recent car accident….I’ve just been busy. Busy writing for columns for the monthly Python Magazine. But that does not mean that his blog is dead! In fact I’ve been spending the last hour looking around the web for something new and cool in the world of Python.
I’m looking for something new to sink my teeth into, something different. I’m looking forward to Python 3000, I’ve been trying to keep up with many of the changes and so far it’s looking really good. But in the mean time there must be something happening in the far off corners of the Python world…where someone is doing something extremely cool.
Please if you have an idea let me know, send me an email, or add a comment to this post. Is there anything that you want me to cover here? A tutorial that you would like? A tutorial that you have written? A new module you wrote? Whatever it is let me know! A new visualization tool? More Python on the web?
I’ve been spending too much time in the world of C++ lately and I’m hungry for some Python…
Popularity: 13%
Posted in Uncategorized, News | 6 Comments »
November 10th, 2007
For this tutorial I’m going to take a look at PyGlet: “a cross-platform windowing and multimedia library for Python.” The reason that I decided to take a look at PyGlet is because it is an alternative to PyGame in the Python gaming world and: “No external dependencies or installation requirements. For most application and game requirements, pyglet needs nothing else besides Python, simplifying distribution and installation.”[1]
The first step to using PyGlet is to actually download it and install it (http://pyglet.org/download.html) as of writing this PyGlet is at version 1.0 alpha 2 (as I finished this tutorial Beta 1 was released but I have been unable to try it out), so between now and the final release there are bound to be a few changes. Once you have download the correct version for your system install it an you are ready to go. I’m writing this on a Debian box so I downloaded the source distribution and installed it using the following, as per the instructions:
python setup.py install
Now like PyGame, PyGlet is a framework for developing games or other applications, it is not a game engine, therefore if you are looking to create a full game you will need to create your own, or use someone else’s. This tutorial will not going into full game creation, instead it will introduce PyGlet using a small sample application, hopefully giving you enough of the basics, or enough of a taste to continue on with it.
You can download the full source to this tutorial here.

![]()
Read the rest of this entry »
Popularity: 31%
Posted in Uncategorized, python, PyGlet | 15 Comments »
October 4th, 2007
The first issue of Python Magazine is finally available and they’ve made it freely available via PDF.
The magazine is quite good and I’m please to announces that I’m writing a monthly column for it entitled “Welcome to Python”. So if any of you are wondering why the posts on this blog have slowed down a little, well it’s because I’ve been trying to do double duty lately, writing posts and columns!
Hopefully I’ll be able to balance the two a little bit better in the future, but for October you can check out my article!
Popularity: 23%
Posted in News, python | 2 Comments »
September 23rd, 2007
PyLan Four
Hello welcome to the fourth installment of the PyLan tutorial. This will be a quick tutorial to introduce one feature: context (or popup) menus. I’ve had many questions regarding this so I thought I would take a quick stab at it.
If you want to follow along with the code in detail, and have not done so already, you should read part one, part two and part three of this series.
You can download the full source to this tutorial here.

Read the rest of this entry »
Popularity: 28%
Posted in python, tutorial, PyGTK, PyLan | 9 Comments »