Pyglet Level Editor

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:

Python Game pyglet editor

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?

Creating a game with PyGlet and Python

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 ( 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 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.

Python Game PyGlet

Continue reading Creating a game with PyGlet and Python