diff options
| author | Ray <[email protected]> | 2019-05-20 16:36:42 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2019-05-20 16:36:42 +0200 |
| commit | b525039e0ab8bcaa2fd6bde34c72a6405f88ae49 (patch) | |
| tree | 08f1c79bfe693643564ed78202c9474b7eb83a79 /examples/shapes/shapes_rectangle_scaling.c | |
| parent | a43a7980a30a52462956b23f2473e8ef8f38d1fb (diff) | |
| download | raylib-b525039e0ab8bcaa2fd6bde34c72a6405f88ae49.tar.gz raylib-b525039e0ab8bcaa2fd6bde34c72a6405f88ae49.zip | |
Review ALL examples
Diffstat (limited to 'examples/shapes/shapes_rectangle_scaling.c')
| -rw-r--r-- | examples/shapes/shapes_rectangle_scaling.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/examples/shapes/shapes_rectangle_scaling.c b/examples/shapes/shapes_rectangle_scaling.c index 036a1dd4..6940cbcd 100644 --- a/examples/shapes/shapes_rectangle_scaling.c +++ b/examples/shapes/shapes_rectangle_scaling.c @@ -15,23 +15,23 @@ #define MOUSE_SCALE_MARK_SIZE 12 -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + const int screenWidth = 800; + const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [shapes] example - rectangle scaling mouse"); - + Rectangle rec = { 100, 100, 200, 80 }; - + Vector2 mousePosition = { 0 }; - + bool mouseScaleReady = false; bool mouseScaleMode = false; - - SetTargetFPS(60); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -40,25 +40,25 @@ int main() // Update //---------------------------------------------------------------------------------- mousePosition = GetMousePosition(); - - if (CheckCollisionPointRec(mousePosition, rec) && + + if (CheckCollisionPointRec(mousePosition, rec) && CheckCollisionPointRec(mousePosition, (Rectangle){ rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, rec.y + rec.height - MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE })) { mouseScaleReady = true; if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) mouseScaleMode = true; } else mouseScaleReady = false; - + if (mouseScaleMode) { mouseScaleReady = true; - + rec.width = (mousePosition.x - rec.x); rec.height = (mousePosition.y - rec.y); - + if (rec.width < MOUSE_SCALE_MARK_SIZE) rec.width = MOUSE_SCALE_MARK_SIZE; if (rec.height < MOUSE_SCALE_MARK_SIZE) rec.height = MOUSE_SCALE_MARK_SIZE; - + if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) mouseScaleMode = false; } //---------------------------------------------------------------------------------- @@ -68,15 +68,15 @@ int main() BeginDrawing(); ClearBackground(RAYWHITE); - + DrawText("Scale rectangle dragging from bottom-right corner!", 10, 10, 20, GRAY); DrawRectangleRec(rec, Fade(GREEN, 0.5f)); - - if (mouseScaleReady) + + if (mouseScaleReady) { DrawRectangleLinesEx(rec, 1, RED); - DrawTriangle((Vector2){ rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, rec.y + rec.height }, + DrawTriangle((Vector2){ rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, rec.y + rec.height }, (Vector2){ rec.x + rec.width, rec.y + rec.height }, (Vector2){ rec.x + rec.width, rec.y + rec.height - MOUSE_SCALE_MARK_SIZE }, RED); } @@ -86,7 +86,7 @@ int main() } // De-Initialization - //-------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- |
