I make apps for other people

Radar Revisited

Posted by Chris Jones
On October 14th, 2009 at 00:08

Permalink | Trackback | Links In |

Comments Off on Radar Revisited
Posted in Python

I’ve been snatching 30 and 60 minute blocks of time in the evenings and on the weekends to get back to work on my Radar test in Python with PyGame from nearly four years ago. PyGame 1.9.1 installed easily on my Windows box and OS X laptop and integrated well with Python 3.1 (on Windows) and Stackless Python 2.6 (on OS X). The only significant changes to be made in the code between Python 2 and Python 3 had to do with exception handling.

So, what’s new and different in this version?

  • I lost my version of Radar that supported chat, so I had to rewrite it from scratch. This version only supports standard layout US keyboards (the shift-modifiers are hard-coded) and I haven’t tweaked the fonts, set up an input box, or limited the input string to make things look nicer.
  • I likewise lost the code to add names and chat messages above the arrow sprites, so I rewrote that. This version should be more correct than the one from 2005.
  • I’m using the standard Python logger (based on log4j) instead of a custom logging class.
  • I’m using a Singleton logger instance for all the arrow sprites.

The arrow sprite logic has gotten complicated enough that I need to develop good unit tests for it. I’ve been developing with rapid integration tests, but I believe I’ve hit the point with the sprite where significant changes could break the correct behavior it’s exhibiting now. A good suite of unit tests against the sprite will help with later refactoring and will also provide a base for testing sprites in other projects. Unit tests should be written before I approach anything as complicated as, say, collision detection (which PyGame handles nicely now) or basic AI or pathfinding.

I’ve looked into using py2exe to package the application as a Windows executable. It looks like, with a few hours of testing and pruning, it’ll work well and still produce a relatively small executable.

I’m considering using Thrift to automate generation and interpretation of the client-server messages. I’m willing to pay a little more in bandwidth and processing time rather than spending time writing custom binary packing and unpacking code for messages. Thrift should let me abstract the process a little more, and I’m very curious to see how well it works for me in practice.

Finally, I’ll implement the server. With the minimal prediction in place on the arrow sprites, I’m very curious to see how well the client runs and how much rubberbanding will take place.

Komodo Edit is still working well for me, although I wonder if the Komodo IDE would help to speed up my develop-test iteration cycle.

Grab the Radar2.zip file here. Install Python 3.1 and Pygame 1.9.1 for 3.1, add Python to your path, and test the program with python Main.py.

Comments are closed.