I have learned a bit about game programming by writing a platform game. Today's post is about the libraries and tools and resources that have been useful in this process.
Graphics
Much of the hard low-level work in the game is done by the SDL library. This library handles drawing graphics and playing sounds in a simple way. Best of all, the library is available for Linux and Windows and several other platforms as well, which makes it simple to write a portable game. I learned how to use SDL from the official documentation and by reading Lazy Foo's tutorials. In addition to the SDL library, we use the following additional modules:
SDL_gfx for drawing primitives and frame-rate control
SDL image for loading images in various formats (png)
SDL mixer for playing sound clips and loading ogg files
Sound
Most of the sounds in the game were generated with the small program sfxr by DrPetter. The program generates sounds with a nice 8-bit feeling. One can tune the sound by changing a set of parameters, like the frequency and wave form. One can also control the sound envelope with attack, decay, sustain, release like on the good old Commodore 64. Sfxr produces wav files. I packed these in the ogg format. In the game code, it is then simple to play the ogg files at appropriate times with the SDL_mixer library.
Data files
I want to minimize the number of files that have to be distributed with the game. Unfortunately the libraries used require a number of dll files (on Windows). But at least one can pack all the game data in a single archive file. So far I have used the zziplib-library to access game files that are packed in a zip file. See also this post for some details on how to get zziplib to work well with SDL. Compiling zziplib on Windows was not trivial, but this I save for another post.
One could also try to pack the game data in the game executable file. Here is a hackish method to create a file that is both the game executable and a valid zip archive, which can be read with zziplib. Another way is to simply compile the data into the exe file. I found that the Linux command-line tool xxd can format a data file as c array (use the flag -i).
Future
An installer system for Windows would be nice. The Nullsoft installer seems promising. Another lighter alternative would be some self-extracting archive.
No comments:
Post a Comment