|
Allegro timers are laggy? |
xantier
Member #12,521
January 2011
|
I'm using ALLEGRO_TIMER objects for my Object class. So every object will have a timer in order to control animation frames. But i am suspicious if too many allegro timers lag the game ? Should I use it ? |
Thomas Fjellstrom
Member #476
June 2000
|
I think they should be fairly efficient. Just make sure that you handle the timer events as soon as you possibly can. Try not to let them pile up. -- |
xantier
Member #12,521
January 2011
|
On each timer tick, i set the tick count 0 (so i can check it easily again). for (int i=0;i<Objects.size();i++) { if (Objects[i]->GetSprite()->IsAnimated()) { if (al_get_timer_count(Objects[i]->GetSprite()->GetTimer())) { al_set_timer_count(Objects[i]->GetSprite()->GetTimer(),0); Objects[i]->GetSprite()->Animate(); } } }
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Why do you need a separate timer for each of your objects? A single 60hz timer should be sufficient for most everything. All you have to do is track delta time in your animated object and set the frame number accordingly. frame_num = (int)(frametime*frames_per_sec); // check bounds of frame_num here...
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|