| 12 | #include "raylib-cpp.hpp" |
| 13 | |
| 14 | int main() { |
| 15 | // Initialization |
| 16 | //-------------------------------------------------------------------------------------- |
| 17 | const int screenWidth = 800; |
| 18 | const int screenHeight = 450; |
| 19 | |
| 20 | raylib::Window window(screenWidth, screenHeight, "raylib [core] example - mouse input"); |
| 21 | |
| 22 | raylib::Vector2 ballPosition(-100.0f, -100.0f); |
| 23 | raylib::Color ballColor = raylib::Color::DarkBlue(); |
| 24 | raylib::Color textColor = raylib::Color::DarkGray(); |
| 25 | |
| 26 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second |
| 27 | //--------------------------------------------------------------------------------------- |
| 28 | |
| 29 | // Main game loop |
| 30 | while (!window.ShouldClose()) { // Detect window close button or ESC key |
| 31 | // Update |
| 32 | //---------------------------------------------------------------------------------- |
| 33 | ballPosition = GetMousePosition(); |
| 34 | |
| 35 | if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON; |
| 36 | else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME; |
| 37 | else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE; |
| 38 | //---------------------------------------------------------------------------------- |
| 39 | |
| 40 | // Draw |
| 41 | //---------------------------------------------------------------------------------- |
| 42 | BeginDrawing(); |
| 43 | { |
| 44 | window.ClearBackground(RAYWHITE); |
| 45 | |
| 46 | ballPosition.DrawCircle(40, ballColor); |
| 47 | |
| 48 | textColor.DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20); |
| 49 | } |
| 50 | EndDrawing(); |
| 51 | //---------------------------------------------------------------------------------- |
| 52 | } |
| 53 | |
| 54 | return 0; |
| 55 | } |
nothing calls this directly
no test coverage detected