[Kde-games-devel] Restructuring and rewriting KGoldrunner
Ian Wadham
ianw2 at optusnet.com.au
Fri Jan 23 05:40:15 CET 2009
On Wed, 21 Jan 2009 10:26:42 pm Parker Coates wrote:
> On Tue, Jan 20, 2009 at 23:37, Ian Wadham wrote:
> > 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.
>
I think KGrLevelPlayer and KGrRunner (with descendants KGrHero and
KGrEnemy) are architecturally something like BaseScene and BaseSprite
and KGrSprite is KGr's graphics sprite. There was briefly a KGrScene
class (re below), but we do not now use QGV's scene/view split.
> 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.
>
I think something like this split already exists in KGoldrunner. I had
to rewrite the graphics code twice in KDE 2 and 3, as well as including
primitive forms of themeing and resizing. Mauricio rewrote it three times
more (for KDE 4) before settling on the KGameCanvas library, which
KGoldrunner currently uses. I don't think the changes were just a few
lines, though ... ;-)
Cheers and all the best with Killbots, Ian W.
More information about the kde-games-devel
mailing list