Well, here is what I have which works GOOD except 1 thing. If you are holding down a direction, then hold down another (to go diagonal for example), there is a slight pause before you start to go in the diagonal direction.
Code:
case WM_KEYDOWN:
{
RECT rcClient;
HDC hDC = GetDC(hWnd);
GetClientRect(hWnd, &rcClient);
switch((int)wParam)
{
case VK_LEFT:
KEY[LEFT] = 1;
break;
case VK_RIGHT:
KEY[RIGHT] = 1;
break;
case VK_UP:
KEY[UP] = 1;
break;
case VK_DOWN:
KEY[DOWN] = 1;
break;
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
UpdateShip(&rcClient, KEY);
DrawShip(hDC, &rcClient);
}
break;
case WM_KEYUP:
{
switch((int)wParam)
{
case VK_LEFT:
KEY[LEFT] = 0;
break;
case VK_RIGHT:
KEY[RIGHT] = 0;
break;
case VK_UP:
KEY[UP] = 0;
break;
case VK_DOWN:
KEY[DOWN] = 0;
break;
}
}
break;