KDE Minigolf Game
November 22, 2008
The window title isn’t misleading: This screenshot shows the first 500 LOC of Kolf 2.0 (codenamed kolf-ng) in action. This might be an unusual view for users who did not develop applications themselves. It looks like this thing cannot do anything, but an expert knows that the inner code might be revolutionary even if it looks ugly.
Well, the code is not very revolutionary, but why do we need a new Kolf at all? Currently, Kolf code is a complete mess. Even its current maintainer (not the original author, though) admits that the source could be maintained, but it has big design flaws which cannot be overcome (esp. after the migration to Qt 4 frameworks). The most prominent example is that every game object consists of three classes. As classes are unfamiliar to some of you, imagine a similar situation in real life: Your car has to be stored divided into three pieces. Each one has its own garage, and every time you want to drive with your car, you have to connect everything and make it work. Every time you will be asking why you have to do this manually.
For Kolf, the situation is essentially the same. The situation gets even worse because of the quirky collision code (just have a look at the bunch of collision detection bugs filed for Kolf). In kolf-ng, I make heavy use of the Qt 4 meta object system to make the code shorter and more readable. The collision code will be rethought and rewritten.
In the screenshot, one can see the first three available objects: wall, rectangle block and ellipse block. For each of these objects, a matching overlay has been added which can be used to edit the object. (The rectangle and ellipse blocks use the same overlay.) The overlays are made up from handles. This architecture will be able to reflect all features of Kolf (except for the putting itself).
This is yet another example that programming is not just about incremental improvements. It’s also about throwing away code and starting on a blank sheet of paper drawing sketches of interacting classes. Luckily, KDE users are familar with this process (just to mention Plasma, KOffice 2, or also Amarok 2).
I know that Kolf is, despite is plenty of bugs, very popular among KDE users. To anyone who would like to play an even better Kolf and get involved with KDE games, and knows some C++, please drop a mail at the kde-games-devel mailing list.