Original Post
Hi, I'm currently studying programming(doing C++) and game dev at a local school, and we've recently started our 2d sprite game projects, and I've encountered a problem that even my tutor isn't sure why it's happening. What it boils down too, is that windows does not seem to be picking up when two keys are released at the same time, which ends up in the character continuing to move in whatever direction he was moving in without any keys being pressed.
I have the following code in my winproc:
What I want to happen, is if either of the movement keys (left and right arrow keys), are released at the same time the attack key(space bar) is hit, for the character to stop moving.
Any advice or suggestions on how I could possibly get this to happen would be great.
I have the following code in my winproc:
case WM_KEYUP:
{
if (VK_LEFT == _wparam)
{
if (HeroSprite->GetDirection() == WALK_LEFT)
{
HeroSprite->StopWalking();
}
}
if (VK_RIGHT == _wparam)
{
if (HeroSprite->GetDirection() == WALK_RIGHT)
{
HeroSprite->StopWalking();
}
}
if (VK_SPACE == _wparam)
{
if (!((GetAsyncKeyState(VK_RIGHT) & 0x8000) == 0x8000) &&
!((GetAsyncKeyState(VK_LEFT) & 0x8000) == 0x8000))
{
if (HeroSprite->GetWalkingState())
{
HeroSprite->StopWalking();
}
}
}
}
break;What I want to happen, is if either of the movement keys (left and right arrow keys), are released at the same time the attack key(space bar) is hit, for the character to stop moving.
Any advice or suggestions on how I could possibly get this to happen would be great.