summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2020-03-24 19:10:50 +0100
committerraysan5 <[email protected]>2020-03-24 19:10:50 +0100
commit05abaee0e092bb2367283e0771a5b628ed9b2282 (patch)
treebcaa1169a6dec164346e00a50ec3eca89a5ac2eb /examples
parentd657537821e430169cf9399122f2cfdf372eb6b3 (diff)
downloadraylib-05abaee0e092bb2367283e0771a5b628ed9b2282.tar.gz
raylib-05abaee0e092bb2367283e0771a5b628ed9b2282.zip
Update core_window_letterbox_virtual_mouse.c
Diffstat (limited to 'examples')
-rw-r--r--examples/core/core_window_letterbox_virtual_mouse.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/examples/core/core_window_letterbox_virtual_mouse.c b/examples/core/core_window_letterbox_virtual_mouse.c
index 87280cdd..37da10be 100644
--- a/examples/core/core_window_letterbox_virtual_mouse.c
+++ b/examples/core/core_window_letterbox_virtual_mouse.c
@@ -16,15 +16,14 @@
#define max(a, b) ((a)>(b)? (a) : (b))
#define min(a, b) ((a)<(b)? (a) : (b))
-/**
- * Clamp Vector2 value with min and max and return a new vector2
- */
-Vector2 Clamp( Vector2 value, Vector2 min, Vector2 max ) {
+// Clamp Vector2 value with min and max and return a new vector2
+Vector2 ClampValue(Vector2 value, Vector2 min, Vector2 max)
+{
Vector2 result = value;
- result.x = ( result.x > max.x ) ? max.x : result.x;
- result.x = ( result.x < min.x ) ? min.x : result.x;
- result.y = ( result.y > max.y ) ? max.y : result.y;
- result.y = ( result.y < min.y ) ? min.y : result.y;
+ result.x = (result.x > max.x)? max.x : result.x;
+ result.x = (result.x < min.x)? min.x : result.x;
+ result.y = (result.y > max.y)? max.y : result.y;
+ result.y = (result.y < min.y)? min.y : result.y;
return result;
}
@@ -63,12 +62,11 @@ int main(void)
//----------------------------------------------------------------------------------
Vector2 mouse = GetMousePosition();
- mouse.x = (mouse.x - ( GetScreenWidth () - ( gameScreenWidth * scale) ) * 0.5) / scale;
- mouse.y = (mouse.y - ( GetScreenHeight () - ( gameScreenHeight * scale) ) * 0.5) / scale;
+ mouse.x = (mouse.x - (GetScreenWidth() - (gameScreenWidth*scale))*0.5f)/scale;
+ mouse.y = (mouse.y - (GetScreenHeight() - (gameScreenHeight*scale))*0.5f)/scale;
// Clamp mouse value behind gamescreen
- mouse = Clamp( mouse, (Vector2){0,0}, (Vector2) { gameScreenWidth, gameScreenHeight } );
-
+ mouse = ClampValue(mouse, (Vector2){ 0, 0 }, (Vector2){ gameScreenWidth, gameScreenHeight });
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE))