So, I've been playing around with WinApi in C++. When i tried some key input i got a problem. I'm using WPARAM along with the WM_CHAR case. This is my input function:
The VK_ESCAPE is working perfectly but the other ones doesn't seem to give any effect. pPosition is a point and is declared global in the beginning of the program:Code:case WM_CHAR:
UpdateGameInput(wParam);
break;
//Later on
void UpdateGameInput(WPARAM wParam)
{
if (wParam == VK_LEFT)
{
pPosition.x += -5;
}
else if (wParam == VK_UP)
{
pPosition.y += -5;
}
else if (wParam == VK_RIGHT)
{
pPosition.x += 5;
}
else if (wParam == VK_DOWN)
{
pPosition.y += 5;
}
else if (wParam == VK_ESCAPE)
{
exit(0x1337);
}
}
I'm using pPosition to draw a rectangle with my HDC and PAINTSTRUCT. The rectangle is showing itself, but it isn't moving the way i want it to:Code:POINT pPosition;
Please help me!Code:case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
Rectangle(hdc,
pPosition.x - 10, pPosition.y - 10,
pPosition.x + 10, pPosition.y + 10);
EndPaint(hwnd, &ps);
break;