Hello There. I recently decided to learn C++, having had much experience with other Programming Languages. To Test my skill, I decided to create a console-based version of the nokia game 'snake'. So far everything is going well, except a small problem with the Keyboard Input. The program operates on a cycle followed by a .5 second delay, to slow down the movement of the 'snake'. The only problem is, if ReadConsoleInput() has no keyboard inputs to read, it pauses the script there until there is. As the snake is supposed to move on its own, This pause is unnessecery and unwanted, and I was wondering how to force the program to continue, or check if there are inputs to read before trying to access them. here is the input code so far. (this is only a small part of the acual code)
if(ReadConsoleInput(Input, &InputRecord, 1, &Events));
{
switch(InputRecord.Event.KeyEvent.wVirtualKeyCode)
{
case VK_UP:
player1.Direction = UP;
break;
case VK_DOWN:
player1.Direction = DOWN;
break;
case VK_RIGHT:
player1.Direction = RIGHT;
break;
case VK_LEFT:
player1.Direction = LEFT;
break;
}
if(ReadConsoleInput(Input, &InputRecord, 1, &Events));
{
switch(InputRecord.Event.KeyEvent.wVirtualKeyCode)
{
case VK_UP:
player1.Direction = UP;
break;
case VK_DOWN:
player1.Direction = DOWN;
break;
case VK_RIGHT:
player1.Direction = RIGHT;
break;
case VK_LEFT:
player1.Direction = LEFT;
break;
}