[Kde-games-devel] Restructuring and rewriting KGoldrunner

Parker Coates parker.coates at gmail.com
Wed Jan 21 12:26:42 CET 2009


On Tue, Jan 20, 2009 at 23:37, Ian Wadham wrote:
> KGrSprite... KGrLevelPlayer... KGrEditor... KGrLevelPlayer...
> KGrGameData... KGrLevelData... KGrLevelGrid... KGrHero... KGrRuleBook

If you're refactoring the code, may I suggest dropping the KGr prefix
from the class names and instead place all your classes in a
KGoldRunner:: namespace? I made this change early in the development
of Killbots and found it made things cleaner and more readable. Of
course, that's almost purely a matter of personal preference, so feel
free to disagree.

> Whilst the main objective is to re-design and re-write the game
> engine, I would also like to make the whole program as much
> as possible Model-View-Controller (MVC).  So the game engine
> will consist of classes descended from QObject (and ideally
> nothing else) and will communicate to the view, sound-player
> and controller code only by signals and slots.

I've just launched a similar effort in Killbots. My Engine class was
already in good shape as it was independent of the graphics system
used, but my Scene and Sprite classes currently contain a mix of code
that provides both basic game functionality and graphical display. To
make the front end / back end separation even cleaner, I've decided to
split those classes into BaseScene, GraphicsViewScene and BaseSprite,
GraphicsViewSprite. The game logic in the Engine class will only use
the Base classes.

So in the future, this would enable me to replace the GraphicsView
classes with QPainter or KGL ones without changing a single line of
existing code other than where those objects are created in the
MainWindow class. I'm not familiar enough with the KGoldRunner code to
know if a similar split makes sense for you, but I thought I'd mention
it as it seems on topic.

Parker


More information about the kde-games-devel mailing list