Allegro timers are laggy?
xantier

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

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

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

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...

Thread #606243. Printed from Allegro.cc