Wednesday, February 29, 2012

Game programming notes

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.

Monday, February 13, 2012

Gray flower cane and beads



A flower cane from black and translucent gray Fimo polymer clay. I experimented with some liquid polymer clay mixed with silver oil paint on a sheet on polymer clay, rolled the sheet up, made cuts into the roll and inserted wedges of black clay, to form a petal. The liquid stuff was a MESS - and it didn't even show in the final cane...



The beads. I realize that translucent clay isn't the best for showing tiny sharp features, since the black shows through the surrounding material, and gets a sort of halo... Made a bracelet, with small gray wooden beads for spacers.

Sunday, February 5, 2012

Magnetic Dodecahedron

five sphere ring dodecahedron from magnetic spheres
Magnetic spheres forming a dodecahedron. Made from twelve five-sphere rings. The rings turn into five-sided polygons when placed side by side in the dodecahedron - this is seen with a flux detector (right).

ten sphere ring dodecahedron from magnetic spheres
 A larger one, made from ten-sphere rings.

fifteen sphere ring dodecahedron from magnetic spheres
The largest one I could make with my set, with fifteen-sphere rings. The dodecahedron was still surprisingly stable, but softer, like an over-ripe orange.

Friday, February 3, 2012

Platform game 0.03 - new release!

Today's release of the platform game adds life to the game world. The controls are simple: move left or right with the arrow keys, and jump with CTRL. The game for Windows, 32 bit Linux and 64 bit Linux. The installation procedure is the same as in the previous version. 

Windows: Download the zip file and extract the folder game003, for example to the desktop. Double-click the file game.exe to run the game. Linux: Download, extract and run. You will need to have the libraries listed in the first game post installed for the game to work.
Newer Older Home
Related Posts Plugin for WordPress, Blogger...