Game Logic
- The actual game logic (enemy AI, player control, map construction etc) is roughly 8,000 lines or 170 kB of C++ code.
- The game logic code is virtually taken as is from XKobo. The only significant change is that there is now a full health/damage system, which is also capable of emulating the old game rules.
- XKobo ran at a fixed frame rate. (The default of 30 ms/frame became the official game speed for Kobo Deluxe. Changing it counts as a cheat!) In Kobo Deluxe, game logic and graphics are decoupled. Scroll and object positions are interpolated for smooth animation at any frame rate.
Graphics
- The graphics engine is about 11,000 lines or 240 kB of C and C++ code.
- The game uses 320 kB of graphics data in PNG format.
- Rendering is done through a sprite engine that was originally written in Object Pascal and 386 assembly language for the DOS game Project Spitfire It was ported to C as a first step in an effort to port Project Spitfire to SDL. The current version implements motion interpolation, manages logic/video frame rate, and contains a graphics manager with a load time image processing pipeline.
- The game artwork is drawn for 640x480, with some remaining graphics for 320x240. Other resolutions (any N:16 factor - game tiles need to be of an exact integer size) are supported by scaling all graphics while loading.
- The graphics engine supports (mostly) transparent scaling (most game code sees a virtual 320x240 display), and includes a low level windowing system with a dirty rectangle manager that automatically governs updates in page flipped video modes.
- The noise and plasma effects are created by blitting one scan line at a time from various small "effect" textures with sine or noise modulated offsets. Fast and simple!
- The animated logo seen in the intro is implemented by rendering various noise and plasma effects through a complex region (a simple scan line based implementation) and then "framing" the result with a logo outline image.
- OpenGL accelerated rendering is implemented through the glSDL wrapper.
Sound
- The audio engine is actually the biggest and most complex part of Kobo Deluxe. It's a total of 21,000 lines or 500 kB of C code, including the EEL scripting engine. (Note: This is not the current VM based incarnation of EEL, but an early interpreting predecessor.)
- Kobo Deluxe has a rather unusual sound system. Most of the sound effects and instrument sounds are scripts rather than the usual sampled waveforms. The scripts render into waveforms as the game loads, or when it's installed.
- The game comes with 69 kB of 8 bit, 8 kHz stereo sound samples, and 59 kB of scripts and MIDI files. The scripts include all instrument sounds used in the music, as well as some of the sound effects.
- The script based sound effects and instruments render into 1.6 MB of raw audio data. The total size of the scripts used is 18 kB, which becomes 3740 Bytes when compressed with bzip2. If you think of it as resynthesis based data compression, that corresponds to a compression ratio of 427:1.
- The original audio code was written by Masanao Izumo, and has been modified, extended and perverted beyond recognition through countless nights of furious, unorganized hacking.
- During the most intensive weeks, the audio engine grew at an average rate of 400 lines of working code per day.
- The unnamed audio engine of Kobo Deluxe has evolved into a stand-alone project named Audiality. Audiality 0.1.x is still compatible with the Kobo Deluxe sound engine, but is considered dead. A complete redesign and rewrite is in progress, and Kobo Deluxe will probably migrate to this eventually.
(Figures and facts apply to Kobo Deluxe 0.4.1)
|