I am trying to make a snakes game in the cosole window that uses the
following code to take keyboard input:
INPUT_RECORD InputRecord;
DWORD Events=0;
ReadConsoleInput(stdIH, &InputRecord, 1, &Events);
if(InputRecord.EventType == KEY_EVENT &&
InputRecord.Event.KeyEvent.bKeyDown)
{
if(InputRecord.Event.KeyEvent.wVirtualKeyCode == VK_RIGHT)
{
setPos(0,0);
cout << "Right!";
}
}
FlushConsoleInputBuffer(stdIH);
It works fine as in when I press right it prints "Right!", but when I
don't press anything it often pauses for several seconds at the
"ReadConsoleInput(stdIH, &InputRecord, 1, &Events);" line, making my
snake animation very jerky.
Anyone know how I could fix this?
-Ed ;-)
following code to take keyboard input:
INPUT_RECORD InputRecord;
DWORD Events=0;
ReadConsoleInput(stdIH, &InputRecord, 1, &Events);
if(InputRecord.EventType == KEY_EVENT &&
InputRecord.Event.KeyEvent.bKeyDown)
{
if(InputRecord.Event.KeyEvent.wVirtualKeyCode == VK_RIGHT)
{
setPos(0,0);
cout << "Right!";
}
}
FlushConsoleInputBuffer(stdIH);
It works fine as in when I press right it prints "Right!", but when I
don't press anything it often pauses for several seconds at the
"ReadConsoleInput(stdIH, &InputRecord, 1, &Events);" line, making my
snake animation very jerky.
Anyone know how I could fix this?
-Ed ;-)
________________________________
Destiny is not a matter of chance; it is a matter of choice.
Destiny is not a matter of chance; it is a matter of choice.