Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Brezo on Mon 23/11/2009 17:14:30

Title: problem with time
Post by: Brezo on Mon 23/11/2009 17:14:30
I want start up an accountant of time (a chronometer) for the presentation and small puzzle that I want to include. Since one becomes? It is necessary to program?
 
Sorry for my english, but i am spanish  ;D
Title: Re: problem with time
Post by: suicidal pencil on Mon 23/11/2009 21:08:01
yes, programing is required. You'd need to keep track of the seconds in time with a variable, and figure out how many minutes (if it takes that long)


int Loops = 0;
int Seconds = 0;
int Minutes = 0;

function repeatedly_execute()
{
  Loops++
  if(Loops == 40) Seconds++;
 Change_Time(Seconds);
}

Change_Time(int time)
{
 if(time == 60)
 {
    Minutes++;
    Second = 0;
    Label1.Text = String.Format("%d:00", Minutes);
    return 0;
 }
 else
 {
    Label1.Text = String.Format("%d:%d", Minutes, Seconds);
    return 0;
 }
}
Title: Re: problem with time
Post by: Brezo on Thu 26/11/2009 17:12:50
Thanks, I will probe  :)
Title: Re: problem with time
Post by: Calin Leafshade on Thu 26/11/2009 18:58:27
The above code will make time move 40 times faster (or what ever the game speed)

Remember that rep_ex runs every game loop, not every second.
Title: Re: problem with time
Post by: suicidal pencil on Thu 26/11/2009 22:15:50
Quote from: Calin Leafshade on Thu 26/11/2009 18:58:27
The above code will make time move 40 times faster (or what ever the game speed)

Remember that rep_ex runs every game loop, not every second.

updated :)