TEMPLATE: CountDown

Started by Joe, Wed 13/09/2006 11:41:50

Previous topic - Next topic

Joe

Hello everyone.

With this template you can make a count down, it's not exactly like a timer, but similar:

Download CountDown template (Requires AGS v2.72 or later)

This template shows hours, minutes and seconds.
Copinstar © Oficial Site

Pedro

Oh this is what I was waiting for, thanks Joe

Joe

#2
Thanks for appreciating my work  :)
Copinstar © Oficial Site

strazer

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

Joe

#4
Ok, thanks for your advice :)
Copinstar © Oficial Site

monkey0506

I think this would work better as a module...if you could work that out...but aside from that it seems okay.

Joe

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
Copinstar © Oficial Site

monkey0506

#7
You could do something like:

Code: ags
// 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.

SMF spam blocked by CleanTalk