core: added GetMouseDelta()

Thanks to previousPosition added by raysan it is now possible to create the GetMouseDelta() function.

Returns a Vector2 with the difference between the current and previous position of the mouse in a frame.

Useful for creating camera scrolling, among others.
This commit is contained in:
Adrian Guerrero Vera 2021-06-16 11:04:43 +02:00
parent 4b93feb172
commit 2b19876123
2 changed files with 12 additions and 0 deletions

View File

@ -3540,6 +3540,17 @@ Vector2 GetMousePosition(void)
return position;
}
// Mouse movement per frame XY
Vector2 GetMouseDelta()
{
Vector2 delta = {0};
delta.x = CORE.Input.Mouse.currentPosition.x - CORE.Input.Mouse.previousPosition.x;
delta.y = CORE.Input.Mouse.currentPosition.y - CORE.Input.Mouse.previousPosition.y;
return delta;
}
// Set mouse position XY
void SetMousePosition(int x, int y)
{

View File

@ -1104,6 +1104,7 @@ RLAPI bool IsMouseButtonUp(int button); // Check if a mous
RLAPI int GetMouseX(void); // Get mouse position X
RLAPI int GetMouseY(void); // Get mouse position Y
RLAPI Vector2 GetMousePosition(void); // Get mouse position XY
RLAPI Vector2 GetMouseDelta(); // Mouse movement per frame XY
RLAPI void SetMousePosition(int x, int y); // Set mouse position XY
RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset
RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling