I know its possible to make timers, but i was wondering if you could implement the computers clock so at different times of day the brightness/darkness of the bgrounds changes or that new locations like a club opens. It could also be used to make an alarm clock with ags.
Here's something I used in my upcoming game when the character looks at a clock...
{
string timebuf; // String that will say "The time is hh:mm."
string minbuf;
string minbufpre;
string horbuf;
string horbufpre;
StrCopy(timebuf, ""); // make the text to display empty
StrCopy(minbuf, ""); // likewise the minutes...
StrCopy(minbufpre, ""); // and all else...
StrCopy(horbuf, ""); // so things won't be cluttered up with multiple text...
StrCopy(horbufpre, ""); // if you click "look" multiple times.
StrFormat(horbufpre, "%d", GetTime (1)); // read the hour into the string
if (GetTime(1) < 10) StrCat(horbuf, "0"); // prefix a 0 if necessary
StrCat(horbuf, horbufpre); // add the hour to the hour-string
StrFormat(minbufpre, "%d", GetTime (2)); // do the same for the minutes
if (GetTime(2) < 10) StrCat(minbuf, "0");
StrCat(minbuf, minbufpre);
StrCat(timebuf, "The time is ");
StrCat(timebuf, horbuf);
StrCat(timebuf, ":");
StrCat(timebuf, minbuf);
StrCat(timebuf, ".");
Display(timebuf); // voila!
}
Here's a simpler snippet that does exactly the same thing:
string time;
StrFormat(time, "The time is %02d:%02d.", GetTime(1), GetTime(2));
Display(time);
StrFormat automatically overwrites the string, so there's no need to clear it with StrCopy. And %02d is replaced with a zero padded string representation of the number. So you could display a score in a pinball machine with %09d for example.
Cheers,
Steve
Thanxs to both of you
Yeah, thanks Steve. I'm still learning...