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

Albert Astals Cid aacid at kde.org
Wed Jun 17 00:06:43 CEST 2009


A Dimarts, 16 de juny de 2009, Ian Wadham va escriure:
> On Tue, 16 Jun 2009 6:37:57 am Albert Astals Cid wrote:
> > A Divendres, 12 de juny de 2009, Ian Wadham va escriure:
> > > 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.
> >
> > Doesn't that mean jerky animation?
>
> No.  I get metronome-like consistency of game action ALL the time,
> which means that running figures always get from A to B in the
> amount of real wall-clock time the player anticipates.  Animation
> is very smooth >99% of the time, but occasionally a frame of
> animation will be skipped, because Qt cannot always keep up
> with real time and misses timer events (that's in the QTimer doco),
>
> > > 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.
> >
> > Hmmm, so you mean now you get jerky animation but game still "runs fast"
> > while previously it was running jerky and slow?
>
> No.  It used to be jerky and fast.  It is now smooth and fast (I have also
> increased the frame rate).

Sounds good :-)

Have you tried comparing it to QTimeline as Alan says?

Albert

>
> A missed animation frame causes a slight flicker or "blip", e.g. the figure
> moved by 4 pixels in 40 msec instead of its normal 2 moves of 2 pixels each
> in 20 msec - total 4 pixels movement in 40 msec in either case.  The effect
> of missing an animation frame is nowhere near as bad as when the human
> player blinks, I would say.
>
> BTW, the technique I am using now might allow KGoldrunner to use
> QGraphicsView some day, although when Mauricio and I last tried
> it, it was sometimes taking up to 900 msec to complete a 60-70 msec
> animation step.  Now *that's* jerky!  It was so slow and unpredictable
> as to make the game actually unplayable at times.  That was in Qt 4.0.
>
> 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




More information about the kde-games-devel mailing list