core: added GetMouseDelta()
(#1832)
* 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. * Added changes noted by raysan
This commit is contained in:
parent
28093c46a8
commit
96d5dd24aa
2 changed files with 12 additions and 0 deletions
11
src/core.c
11
src/core.c
|
@ -3537,6 +3537,17 @@ Vector2 GetMousePosition(void)
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get mouse delta between frames
|
||||||
|
Vector2 GetMouseDelta(void)
|
||||||
|
{
|
||||||
|
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
|
// Set mouse position XY
|
||||||
void SetMousePosition(int x, int y)
|
void SetMousePosition(int x, int y)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1113,6 +1113,7 @@ RLAPI bool IsMouseButtonUp(int button); // Check if a mous
|
||||||
RLAPI int GetMouseX(void); // Get mouse position X
|
RLAPI int GetMouseX(void); // Get mouse position X
|
||||||
RLAPI int GetMouseY(void); // Get mouse position Y
|
RLAPI int GetMouseY(void); // Get mouse position Y
|
||||||
RLAPI Vector2 GetMousePosition(void); // Get mouse position XY
|
RLAPI Vector2 GetMousePosition(void); // Get mouse position XY
|
||||||
|
RLAPI Vector2 GetMouseDelta(void); // Get mouse delta between frames
|
||||||
RLAPI void SetMousePosition(int x, int y); // Set mouse position XY
|
RLAPI void SetMousePosition(int x, int y); // Set mouse position XY
|
||||||
RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset
|
RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset
|
||||||
RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling
|
RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue