diff options
| author | Adrian Guerrero Vera <[email protected]> | 2021-06-21 00:11:27 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-21 00:11:27 +0200 |
| commit | 96d5dd24aa8054c0daebb495bea25a2da0a7340e (patch) | |
| tree | a9cff3f0d0d5c8734c7eab11fafa393f349c3e0d /src/core.c | |
| parent | 28093c46a8d264206936d2eb534c56173346020b (diff) | |
| download | raylib-96d5dd24aa8054c0daebb495bea25a2da0a7340e.tar.gz raylib-96d5dd24aa8054c0daebb495bea25a2da0a7340e.zip | |
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
Diffstat (limited to 'src/core.c')
| -rw-r--r-- | src/core.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -3537,6 +3537,17 @@ Vector2 GetMousePosition(void) 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 void SetMousePosition(int x, int y) { |
