[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-games-devel
Subject:    [Kde-games-devel] Question/Idea KSprite
From:       Martin <martin () heni-online ! de>
Date:       2001-09-20 17:21:48
[Download RAW message or body]

Hiya,

while converting kwin4 to QCanvas I found it quite helpful to reuse one of my 
old classes from quintalign, namely some KSprite classes, which are easier to 
use than the QCanvasSprite classes. Although they are not (yet) written
for general use I would like to show them to you. If some of you find them of
use we could work on integrating them into the libkdegames. If not I can
save the trouble to generalize them and just keep them in my games.

I hacked in a short doc (I know it has plenty of typos, so don't get me on 
them) which you can read on 
http://www.heni-online.de/libkdegames/sprite
The docs are not exceedingly comprehensive but someone who has programmed
sprites before might get the idea.
There are two public classes to consider:
1. KSprite: inherits QCanvasSprite and extens it by
  - Improved and more animation modes than even the qt3 sprites
  - implemtents better movement control (or will)
  - it can (optionally) emit signals when movment or single shot animation 
    are over. The class does not inherit QObject though.

2. KSpriteCache:
   provides a cache for sprites. Once loaded you can easily clone them
   from there. You get a sprite via a name e.g.
   KSprite *sprite=getItem("piece",4242); 
   will clone you a sprite. 
   All properties of the sprite can be confgiured via a KConfig rc
   file.  This includes animations, scaling, color changing, ...
   So the definition of the sprites, what filename, animations,
   even positions can be made independent of the c++ code.


Both classes are neither optimized for efficenice nor anything else. But
they kind work and they are extremely easy to use.
I am not convinced they are of general interest. Most profit is
problably for games like the two mentioned above, especially
if you use a lot of similar sprites with some of animations. Or
if you want to do theming or have some external guy doing the
graphics who need not bother to change the c++ code.

So any feedback is welcome.

Martin

PS: if you are interest in the actual code checkout the 
kdegames/kwin4 directory in kwin4/kspriteache you find the classes.





   






_______________________________________________
Kde-games-devel mailing list
Kde-games-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-games-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic