From 183795b8aa78fdf0b8064d72d77eaea8e7b6397b Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 16 Jan 2016 12:52:55 +0100 Subject: Review literals type --- examples/core_input_mouse.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'examples/core_input_mouse.c') diff --git a/examples/core_input_mouse.c b/examples/core_input_mouse.c index c64b421e..358b5fd6 100644 --- a/examples/core_input_mouse.c +++ b/examples/core_input_mouse.c @@ -20,8 +20,9 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input"); - int mouseX, mouseY; - Vector2 ballPosition = { -100.0, -100.0 }; + Vector2 ballPosition = { -100.0f, -100.0f }; + + SetTargetFPS(60); //--------------------------------------------------------------------------------------- // Main game loop @@ -31,11 +32,7 @@ int main() //---------------------------------------------------------------------------------- if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { - mouseX = GetMouseX(); - mouseY = GetMouseY(); - - ballPosition.x = (float)mouseX; - ballPosition.y = (float)mouseY; + ballPosition = GetMousePosition(); } //---------------------------------------------------------------------------------- -- cgit v1.2.3 From 8aab52aeda47ce283d1446be27a7e2e20f027434 Mon Sep 17 00:00:00 2001 From: Ray San Date: Thu, 18 Feb 2016 14:05:48 +0100 Subject: Redesigned RPI input system -IN PROGRESS- --- examples/core_input_mouse.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'examples/core_input_mouse.c') diff --git a/examples/core_input_mouse.c b/examples/core_input_mouse.c index 358b5fd6..24d2dfcd 100644 --- a/examples/core_input_mouse.c +++ b/examples/core_input_mouse.c @@ -21,6 +21,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input"); Vector2 ballPosition = { -100.0f, -100.0f }; + Color ballColor = DARKBLUE; SetTargetFPS(60); //--------------------------------------------------------------------------------------- @@ -30,10 +31,11 @@ int main() { // Update //---------------------------------------------------------------------------------- - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - ballPosition = GetMousePosition(); - } + ballPosition = GetMousePosition(); + + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON; + else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME; + else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE; //---------------------------------------------------------------------------------- // Draw @@ -42,9 +44,9 @@ int main() ClearBackground(RAYWHITE); - DrawCircleV(ballPosition, 40, GOLD); + DrawCircleV(ballPosition, 40, ballColor); - DrawText("mouse click to draw the ball", 10, 10, 20, DARKGRAY); + DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY); EndDrawing(); //---------------------------------------------------------------------------------- -- cgit v1.2.3