Chapter 4. Developer's Guide to Killbots

Interested individuals can customize Killbots in two major ways: themes and rulesets.

Creating Custom Killbots Themes

Like most other KDE games, a Killbots theme consists of three files.

The Desktop File

The desktop file follows standard INI syntax. The key-value pairs store information about the theme and point to the other files included in the theme. The following example is taken from the default theme.

Example 4.1. An Example Theme Desktop File

[KGameTheme]
Name=Example Theme
Description=An example theme used to demonstrate theme creation. This one features pirates.
Author=Mr. Artist
AuthorEmail=mrartist@example.com
Type=SVG
FileName=example.svg
Preview=example.png
        

The first four parameters contain metadata about the theme and are straight forward enough. For Killbots themes, the Type parameter should always be set to SVG. The final two parameters contain the file names of the two other theme files. While it's not strictly necessary, it is highly recommended that, for consistency's sake, all three files share the same base file name.

The Preview File

The preview file is simply a PNG file containing a preview of the theme. The preview image should be 240 by 140 pixels and match layout of the default theme's preview as closely as possible, as this makes it easier to compare themes in the theme selector.

The SVG File

The SVG file is a scalable vector graphics image that contains the actual graphical elements used to make up the theme. The file may be either in uncompressed .svg or compressed .svgz format. Each game element is identified by a unique id in the SVG file. When creating a new theme, it is generally easiest to start with an existing theme and replace the elements one by one until the theme is complete. The SVG file must contain the following elements.

background

The image displayed behind the grid in the main game area.

status

The box used to display the current round, score, enemy count and energy.

textcolor

This element should be a rectangle of a single color. Its color is used to for the text in the status boxes.

cell

An individual grid cell.

hero

The character controlled by the player.

enemy

The basic enemy.

fastenemy

The faster enemy.

junkheap

The remains of a collision between enemies.

cursor0

A cursor indicating movement to the right.

cursor1

A cursor indicating diagonal movement up and to the right.

cursor2

A cursor indicating movement up.

cursor3

A cursor indicating diagonal movement up and to the left.

cursor4

A cursor indicating movement to the left.

cursor5

A cursor indicating diagonal movement down and to the left.

cursor6

A cursor indicating movement down.

cursor7

A cursor indicating movement down and to the right.

cursor8

A cursor indicating staying in place.

Installing Custom Themes

In order for Killbots to detect and use a new theme, the files must be moved to an appropriate directory. To install the theme for only the current user, copy the desktop, preview and SVG files to $KDEHOME/share/apps/killbots/themes. To make the theme available system wide, move the files to `kde-config --prefix`/share/apps/killbots/themes. Note that this will likely require administrative privileges.