By using GetAsyncKeyState, I can get objects to move, however, this function is based solely on what the keyboard delay and repeat rates are as set in windows and is bad for games and interactive animations. In my case, it's 250 milliseconds delay and 30 repeats per second afterwards. I need it so that the state of the key is checked each frame causing no delays at all. This is my code (for the relevant area near the bottom) if it helps:
Code:
while(GameRunning == 1) // while the game is running
{
PeekMessage(&msg,hwnd,NULL,NULL,PM_REMOVE);
if (msg.message == WM_QUIT) // check for a quit message
{
GameRunning = 0; // if found, quit the game
}
else
{
AdvanceClock(); // advance the clock forward one frame
if (FramesDrawn < 4000) // test only
{
ProcessFrameData(); // obtains the image for displaying
}
// After this, we display the finished image.
if (FramesDrawn < 5000) // again, test only
{
// display the output obtained in the previous function call
DrawDibDraw(ImageHandle, HDCScreen, 0, 0, MainDisplayHead.biWidth, MainDisplayHead.biHeight, BMPHeadPointer, BMPImagePointer, 0, 0, MainDisplayHead.biWidth, MainDisplayHead.biHeight, NULL);
FramesDrawn++;
}
if (FramesDrawn < 4000) // yep, gotta love tests
{
// The state of the keys should be checked every time a frame is processed
if (GetAsyncKeyState(KeyUp) == KeyOn) // KeyUp is 0x26 and KeyOn is defined as -32767 (from an experiment)
{
TestImage.y--; // moves test image up
}
if (GetAsyncKeyState(KeyDown) == KeyOn) // KeyDown is 0x28
{
TestImage.y++; // moves test image down
}
}
/* Translate and dispatch to event queue */
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Edit: It won't let me color the text. It's the bottom area in question.