Game Development Community

Game Clock: Time Remaining

by Mychal McCabe · in Torque Game Engine · 02/09/2002 (10:04 am) · 3 replies

I was wondering if anyone had implemented a clock that counts time remaining in a game, and if so if they had any pointers or code they'd be willing to share.

one of our programmers pointed me in the following direction:

***

$Game::StartTime is set to some number of milliseconds when the game starts, and then you can later check $Sim::Time and compare it to $Game::StartTime to see how much time has elapsed, and from that calculate what to display. (Of course, you'd need to know how to display big numbers in a nice font.)

So, the other part of that would be arranging for that code to be called regularly; as I mentioned before, I don't think there's any entry point to the scripting that is regularly polled, but there's probably some way to arrange for future callbacks, so that the code could show the clock, set a callback to run itself again in one second, repeat.

***

This is a little less opaque than Greek to me, so I'll monkey around with this today, and post results as I come up with them.

Thanks.

mychal mccabe
badlands games
mychal@badlandsgames.com

#1
02/10/2002 (5:24 am)
The GuiHudClock control in Torque 1.1.1 would seem to be your best bet for reference. You can find the C++ source for the control in the engine/game/fps directory.

Justin Mette
21-6 Productions
#2
02/11/2002 (3:51 am)
The clock starts at zero and increases after each second.

So.... just do it in reverse :P
#3
02/11/2002 (9:21 pm)
And it's that easy. ;\/ Thanks for the pointers.