herdem_timer.c
/**
 * Iteration handler, updates the timer with the correct
 * time
 */
Iteration handler, updates the timer with the correct
time
Iteration handler updates the timer with the correct time
void herdem_timer_update(jty_actor *actor)
{
    jty_txt_actor *timer = (jty_txt_actor *)actor;
    int time_remaining = (int)herdem_engine->time_limit - (int)herdem_engine->level_time;
    int minutes_elapsed = time_remaining / 1000. / 60.;
    int seconds_elapsed = (int)(time_remaining / 1000.)  % 60;
    char timer_text[200];
    char red[] = "0000ff"; 
    char white[] = "ffffff"; 
    char *text_colour;
    if (time_remaining <= 6 * 1000)
        text_colour = red;
    else
        text_colour = white;
    sprintf(
            timer_text,
            "<span foreground=\"#%s\" >%i:%02i</span>",
            text_colour,
            minutes_elapsed,
            seconds_elapsed);
    jty_txt_actor_set_text(timer, timer_text);
    return;
}
void herdem_timer_update ( jty_actor * actor ) { jty_txt_actor * timer = ( jty_txt_actor * ) actor ; int time_remaining = ( int ) herdem_engine -> time_limit - ( int ) herdem_engine -> level_time ; int minutes_elapsed = time_remaining / 1000. / 60. ; int seconds_elapsed = ( int ) ( time_remaining / 1000. ) % 60 ; char timer_text [ 200 ] ; char red [ ] = " " ; char white [ ] = " " ; char * text_colour ; if ( time_remaining <= 6 * 1000 ) text_colour = red ; else text_colour = white ; sprintf ( timer_text , " \" \" " , text_colour , minutes_elapsed , seconds_elapsed ) ; jty_txt_actor_set_text ( timer , timer_text ) ; return ; }
Iteration handler, updates the timer with the correct
 time
Iteration handler updates the timer with the correct time