[Kde-games-devel] A timer class for games

Kleag kleag at free.fr
Fri Jun 12 21:59:04 CEST 2009


Hello Ian,

This seems interesting and I probably could use it in ksirk. 

But I wonder if it is really necesssary: could the new animation framework 
that will be available with Qt replace our adhoc animation codes ?

Bye,

Gaël
Le vendredi 12 juin 2009 09:15:52 Ian Wadham, vous avez écrit :
> During the re-write of KGoldrunner I have developed a timer
> class that gives greater reliability to animation-timing and a
> smoother overall animation effect.  I am wondering if it is worth
> generalizing it into a KDE Games Library class for KDE 4.4,
> i.e. whether other games could find it useful.
>
> Although its accuracy cannot be better than QTimer's, which
> is to say QObject's accuracy, it checks its performance against
> real time (wall-clock time) and compensates for "beats" that
> QTimer misses, i.e. if you ask for a beat every 20 msec, you
> get 50 beats/second, no matter what the Qt library decides to
> do, although not all beats are exactly on time and some are
> rapidly-executed catch-ups.
>
> Other bonuses are that it implements pause(), resume() and
> step() methods, to accuracy within one beat, so if you are running
> a game off a single timer, it gives you instant pause/resume.
> And the step() method is very handy for debugging animation.
>
> There is also a setScale() method which is useful for speeding
> up or slowing down the whole game.  The tick() signal emitted
> by the timer has parameters that tell you whether a beat has been
> missed (by QObject) and what the scaled time of the tick is.
>
> In KGoldrunner, I use the "missed" parameter to skip an animation
> frame in the graphics, while keeping the internal model and the
> overall motion (distance travelled per second) on time.  That
> should relieve the load on the CPU and graphics and, at worst, it
> causes an occasional flickering, which is not as bad as it already
> was (all the time) in KDE 3 and KDE 4.0 to 4.2.
>
> The code is in kgoldrunner/src/kgrtimer.h and
> kgoldrunner/src/kgrtimer.cpp, but it needs polishing.
>
> All the best, Ian W.
> _______________________________________________
> kde-games-devel mailing list
> kde-games-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kde-games-devel

-- 
KsirK - a world domination strategy game 
http://techbase.kde.org/Projects/Games/Tactic_and_Strategy/KsirK

KGraphViewer - a GraphViz dot graphs viewer
http://extragear.kde.org/apps/kgraphviewer



More information about the kde-games-devel mailing list