Monday, May 01, 2006

More on Python and OpenGL

Made a few changes to the program. It now starts at a pre-chosen hex with the camera set at a pre-chosen angle. You can now click on a hex and the camera will smoothly center on that new hex. Your camera angle will remain the same. You can also use the Q, W, A, S, D and Z keys as before to adjust your camera angle.

The source code can be found at: TW_05.py

I also got the py2exe program working and you can now download the zipped executable at: tw_05.zip

There's seems to be some problem between the pyOpenGl and the py2exe. After the compile, pyOpenGl looks for a 'version' file in the library.zip, but the py2exe program didn't include it. I tried including it manually but it still couldn't see it. The solution involved modifying the pyOpenGL __init__.py file to capture the file error and set the version manually if the file couldn't be found.

I haven't gotten around to figuring out how to minimize the build size, so the complete build comes in at around 8 meg. Quite a large program for doing so little. You can see that the source code is actually quite small (17 kB) the rest is all the Python interpreter, pyGame and pyOpenGL.

I extended the Camera Class, but now there's some unused pieces of it that I haven't removed yet. (like the move_x and move_y). I also added set target and initialize position routines that handle setting up the desired target hex and initializing the camera target to that hex.

I did run into a little problem with some floating point errors. At one point I was getting a 'True' returned for '6.0'

Next step will be to place some user-controllable 'characters' on the board and let the user move them about and interact with them.