![]() |
| | #1 |
| Banned Join Date: Sep 2002
Posts: 6,334
| FAQ: Timers in C++ In C++ i want to set a time limit on my game. Not with decrements in for loops or anything, but with a timer, i think the functions i am looking for are in ctime.h or something like that. Thanks! say int timer = 600(seconds) while (timer >=1 || do_this != 'Q') { ..... } |
| RoD is offline |
| | #2 |
| Confused Join Date: Sep 2001 Location: Sweden
Posts: 3,122
| In windows.h, there is GetTickCount(), returning the number of milliseconds since windows started. You could use that. Code: DWORD StartTime = GetTickCount()
DWORD TimeFrame = 1000 * 60;
while((GetTickCount() - StartTime) < TimeFrame)
{
...
}
__________________ MagosX.com Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. |
| Magos is offline |
| | #3 |
| Banned Join Date: Sep 2002
Posts: 6,334
| Thanks, that did it. |
| RoD is offline |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wiki FAQ | dwks | General Discussions | 192 | 04-29-2008 01:17 PM |
| FAQ Check/Lock | RoD | A Brief History of Cprogramming.com | 2 | 10-15-2002 11:21 AM |
| Timers | Mox | Windows Programming | 2 | 11-09-2001 04:34 AM |