I am trying to get a keyboard input, but if it doesn't happen in about half a second I want it to continue to the rest of the loop. I tried using kbhit(); but it won't wait for the input, it just loops with out stopping. This is the loop in question:
    while(flags)
{
    gameing.updateDraw(0, 0);
    keyIn = getch();
    //Sleep(20);
    switch(keyIn)
    {
        case UP_ARROW:
                flags = gameing.updateDraw(-1, 1);
                break;
        case DOWN_ARROW:
                flags = gameing.updateDraw(1, 1);
                break;
        case WKEY:
                flags = gameing.updateDraw(-1, 2);
                break;
        case SKEY:
                flags = gameing.updateDraw(1, 2);
                break;
    }
All help will be greatly appreciated. I am trying to avoid using alarm();
                        
The comnented call to
Sleepindicates that this is a Windows program using<conio.h>functionality, and not a *nix program using curses.With
<conio.h>you can use thekbhitfunction to check whether there is a keypress.Place that in a loop that sleeps a little bit between each call.
More advanced you can use the Windows API. Its wait functions can wait on a console handle, with a specified timeout.
The C++ standard library does not have unbuffered keyboard input functionality.