shh....
Printable View
shh....
I think I have an idea based on FillYourBrains reply... I'll try it and then tell you how it went.
Doesn't seem to work... How can I get the timer to run in the background? I tried running it in a loop with a while(!kbhit).
Post the rest of your code.
Code:time_t timerTime = time(NULL) + (60*60);
while (time(NULL) < timerTime)
{
while (!kbhit)
{
// Do animation;
}
int iKeyCode = getch();
switch (iKeyCode)
{
// Do movement;
}
}
There is no "background" unless you're multithreaded or at least message based as windows is. You're doing a DOS game if I'm not mistaken. You should have a game loop that controls animation based on a time check. This same time check can be used to figure out if your "countdown" has expired. What didn't work?Quote:
Originally posted by drdroid
Doesn't seem to work... How can I get the timer to run in the background? I tried running it in a loop with a while(!kbhit).
Basically I did what you posted... but it still pauses when it counts down... it stops the character from moving for the timer to wait and then subtract to the time left... is that any help?
no, you probably misunderstood what I said.
most games have a "game loop". This is a place where all motion is decided and drawn to the screen. If you simply check what time it is one time in this loop you will be checking once for every screen drawn. There would be no pause. You were probably thinking putting the timer in a loop of its own. that's not at all what I suggested.