diff options
| author | Ray <raysan5@gmail.com> | 2016-02-20 01:09:47 +0100 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2016-02-20 01:09:47 +0100 |
| commit | 4b6e6d4dd45fc3a47b82af7eeb60871140a7eccf (patch) | |
| tree | d9ee679c3b0bc5d4a20b31930994deb0e4c37948 /examples/core_input_mouse.c | |
| parent | f582ab06add085594f2579ee6e7d625212abd204 (diff) | |
| parent | 954ced21a42eb489ad382b4c00406a28778fee41 (diff) | |
| download | raylib-4b6e6d4dd45fc3a47b82af7eeb60871140a7eccf.tar.gz raylib-4b6e6d4dd45fc3a47b82af7eeb60871140a7eccf.zip | |
Merge pull request #83 from raysan5/develop
Develop branch integration
Diffstat (limited to 'examples/core_input_mouse.c')
| -rw-r--r-- | examples/core_input_mouse.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/examples/core_input_mouse.c b/examples/core_input_mouse.c index c64b421e..24d2dfcd 100644 --- a/examples/core_input_mouse.c +++ b/examples/core_input_mouse.c @@ -20,8 +20,10 @@ 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 }; + Color ballColor = DARKBLUE; + + SetTargetFPS(60); //--------------------------------------------------------------------------------------- // Main game loop @@ -29,14 +31,11 @@ int main() { // Update //---------------------------------------------------------------------------------- - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - mouseX = GetMouseX(); - mouseY = GetMouseY(); - - ballPosition.x = (float)mouseX; - ballPosition.y = (float)mouseY; - } + 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 @@ -45,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(); //---------------------------------------------------------------------------------- |
