Hello everyone.
With this template you can make a count down, it's not exactly like a timer, but similar:
Download CountDown template (http://www.fileupyours.com/files/59182/CountDown.rar) (Requires AGS v2.72 or later)
This template shows hours, minutes and seconds.
Oh this is what I was waiting for, thanks Joe
Thanks for appreciating my work :)
(This is just a template, not a module.)
Joe, please always state which version of AGS is required to use your stuff (for templates, state the version you made it with).
Ok, thanks for your advice :)
I think this would work better as a module...if you could work that out...but aside from that it seems okay.
I know it should be a module but if I load just the module, it wouldnt be enough because it need a GUI to show the countdown, but if there is a way to make it through an overlay, please tell me. :o
You could do something like:
// module script
struct CountdownType {
Overlay* o;
int timer;
int hours;
int mins;
int secs;
import void SetTime(int hours, int mins, int secs);
};
void CountdownType::SetTime(int hours, int mins, int secs) {
if (hours < 0) hours = 0;
if (mins < 0) mins = 0;
if (mins >= 60) mins = 59;
if (secs < 0) secs = 0;
if (secs >= 60) secs = 59; // yeah...I'm feeling lazy....this could be handled better...
this.hours = hours;
this.mins = mins;
this.secs = secs;
}
CountdownType Countdown;
// rep_ex
if ((!Countdown.timer) && ((Countdown.secs) || (Countdown.mins) || (Countdown.hours))) {
Countdown.secs--;
if (Countdown.secs < 0) {
Countdown.mins--;
Countdown.secs = 59;
}
if (Countdown.mins < 0) {
Countdown.hours--;
Countdown.mins = 59;
}
Countdown.o = Overlay.CreateTextual(X, Y, WIDTH, FONT, COLOR, String.Format("%d:%d:%d", Countdown.hours, Countdown.mins, Countdown.secs));
Countdown.timer = GetGameSpeed();
}
else Countdown.timer--;
Of course none of that is tested...and I didn't actually look at your code to see what you'd already done either. But hopefully this should give you some ideas.