Posts in April, 2007

I recently posted a path finding demo that uses a breadth-first algorithm to route a sprite around a map. Kamilche has taken the basic idea and created a new demo with many improvements. Fugu has been replaced with an animated turtle that uses the A* algorithm to do the path finding. A* (pronounced "A star") generally performs better than breadth-first search because it directs the search towards the target, rather than have it expand evenly.

Kamilche is the author of Incarnation, an impressive RPG written in Python & PyGame. I highly recommend checking it out!

So you are writing a game in PyGame and you come up with the most beautiful particle effect. But when you implement it, you find that the particles seem to jitter between pixels, and it spoils the effect. This is because PyGame can only render sprites at integer coordinates, even if you give it float values. OpenGL or other 3D APIs don't suffer from this because they can apply filtering and effectively render images between pixels (or sub-pixel). But you can't do that with a 2D blitter.

Until now that is! :-) I've written a small module that pre-calculates sub-pixel sprites so that you can render a PyGame surface at fractional coordinates. It's nice and easy to use, and is almost a drop in replacement. Here's an example: continue reading…

I have written a demonstration of a simple path-finding algorithm (in Python), for use in grid-based computer games. It used a breadth-first search to route a sprite from one part of a map to another, avoiding obstacles in between. The code is a listing taken from my forthcoming book, Beginning Game Development with Python and Pygame

To run it, you will need PyGame, and of course Python. The code is completely public domain, use it for whatever purpose you want and you don't owe me a penny. Here be a screenshot...

The other day I noticed that the words 'kiss' and 'lips' (don't ask) could be spelled on the same buttons when texting on a phone. I idly wondered what other related words could be spelled on identical buttons. That idle wondering festered in my brain and eventually turned in to a Python script (which is often the result of my wonderings). The script I wrote, groups words together by the sequence of phone buttons needed to txt them. It also filters out sequences with just one word, which I wasn't interested in. Here is the code:

Next I scanned through the output to find related words. I guess this could be done automatically if I had access to a thesaurus file, but that seemed more trouble that it is worth. Here are a few I picked out...

[24453] AGILE CHILD - A fast moving kid? continue reading…

My sister sent me this (hi Jen), it is a lesson in not taking computers literally. According to Google, if you want to go from New York to Edinburgh you must swim across the Atlantic ocean. Nice going egg-heads!

It must have been a slow news day in Chester yesterday. Front page on the Chester Chronicle is an article about a painting of Adam and Even hanging in the Cathedral. Apparently some locals were grossly offended at the sight of Eve's buttocks and breast. I'm tempted to get all militant atheist here, but I know its just a handful of stuffy prudes. Personally I think Eve looks quite good, and no cellulite in sight! Judge for yourself...

Last week I started a new job as a full time Python developer. Prior to that I worked for a computer games company called  Evolution Studios. Evos - as it is affectionately known by employees - achieved a great deal of success with its latest game, Motorstorm, and it looks like they are set to keep producing hit games. There are a lot of great things about working for a games company, and being a games programmer gets you a lot of respect amongst certain circles (i.e. game geeks). So why give it up? Well over the last few years I have fallen in love with Python and I use it at every opportunity. Consequently I have been idly keeping an eye on the Python job board for Python related work and came across a job that I was perfectly suited for. It listed requirements for skills that I thought were incidental, and the work I would be been doing is not dissimilar to the type of Python coding I do to amuse myself in my spare time. Not sure if I can tell you about it yet, I would have to clear that with the boss. Did I say 'boss'? I meant client, because now I am now self-employed! continue reading…