[Kde-games-devel] kblocks: separate the game logic and the display logic?

Ian Wadham ianw2 at optusnet.com.au
Fri Oct 9 00:10:05 CEST 2009


On Fri, 9 Oct 2009 12:37:26 am Mauricio Piacentini wrote:
> On Thu, Oct 8, 2009 at 10:25 AM, Dapeng Zhang wrote:
> > In past a few days, we analyzed the source code of KBlocks. Here is the
> > "class diagram" in UML (the screen shot of "dia").
> >
> > http://allheim.informatik.uni-freiburg.de/~zhangd/KBlocks.png
> >
> > We found that the game logic and display logic are mixed together. For
> > example, KBlocksScene is such a class.
> >
> > In order to develop the two-player mode, I wonder if we could first
> > isolate the game logic, which will result in some significant changes on
> > the class view. If it is acceptable, I will send the proposed class
> > diagram in next a few days.
> >
> > What do you think?
>
> Hey, very cool. Please go for it. I am interested in your proposal to
> isolate this inside the QGV framework, could be something useful in
> the future for other games and projects.
>
Yes indeed.

Believe it or not, I have been tinkering with QGV in the last few weeks ...
but not for KGoldrunner!  Although QGraphicsScene, from which one inherits,
is just a descendant of QObject, it does not seem to be completely independent
of QGraphicsView.  For example, it does coordinate transformations, but
apparently only into a wider "canvas" measured in pixels from the top left.

Many 2-D games need to have their own coordinate system, even if is only
(row number, column number) in a tiled grid, and the game logic needs to
be completely independent of how many pixels represent an object on the
physical screen IMO.  I like the OpenGL approach, where the scene is of
infinite extent in whatever coordinates you like and you only have to define
the boundaries of the view.

All the best, Ian W.





More information about the kde-games-devel mailing list