reading a key input

::CONSOLE APPLICATION::
I was wondering if there was a way to read a keyboard input
Now read on
I have a while loop that controls the 'game'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
while(playing)
{
    system("CLS");
    drawBoard(board);
    
    //now heres where I need a keyboard read
    if(keyboard key has been pressed)
        //update player's position
    else
        //just keep doing what you were doing

    if(error) //<-just a condensed version here for 'game over'
        playing = false;
}
problem with cin and getch is that they interupt the flow and wait on the user to press a key. which is NOT what I want. I want the game to continue its normal process and just update the player's position IF they pressed a key.
Last edited on
http://www.cprogramming.com/fod/kbhit.html
i'm not sure but it should return the pressed key
Topic archived. No new replies allowed.