Skip to content

Commit

Permalink
feat: add the ability to move the sprite using the mouse wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKonstantinSh committed Sep 15, 2020
1 parent 9d14586 commit f589441
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Lab_1/Lab_1/Lab_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,34 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
}
break;
case WM_MOUSEWHEEL:
if (GET_KEYSTATE_WPARAM(wParam) == MK_SHIFT)
{
if (GET_WHEEL_DELTA_WPARAM(wParam) > 0)
{
spritePosition = CreateNewSpritePosition(spritePosition, CreateLeftSteps(), hWnd, sprite);
PostUpdateSpriteMessage(hWnd);
}
else
{
spritePosition = CreateNewSpritePosition(spritePosition, CreateRightSteps(), hWnd, sprite);
PostUpdateSpriteMessage(hWnd);
}
}
else
{
if (GET_WHEEL_DELTA_WPARAM(wParam) > 0)
{
spritePosition = CreateNewSpritePosition(spritePosition, CreateUpSteps(), hWnd, sprite);
PostUpdateSpriteMessage(hWnd);
}
else
{
spritePosition = CreateNewSpritePosition(spritePosition, CreateDownSteps(), hWnd, sprite);
PostUpdateSpriteMessage(hWnd);
}
}
break;
case WM_SIZE:
PostUpdateSpriteMessage(hWnd);
return DefWindowProc(hWnd, message, wParam, lParam);
Expand Down

0 comments on commit f589441

Please sign in to comment.