diff options
| author | raysan5 <raysan5@gmail.com> | 2019-07-28 15:09:01 +0200 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2019-07-28 15:09:01 +0200 |
| commit | 602d2a65dd628ea75801c79bfdf960b081696e34 (patch) | |
| tree | a5a3eb31e93131abcc2280b8a6cba93b4a25ec61 /examples/core | |
| parent | 879c874330e2946ca0dcce74a5dfbe852b4d1f4a (diff) | |
| download | raylib-602d2a65dd628ea75801c79bfdf960b081696e34.tar.gz raylib-602d2a65dd628ea75801c79bfdf960b081696e34.zip | |
Reviewed new examples
Diffstat (limited to 'examples/core')
| -rw-r--r-- | examples/core/core_scissor_test.c | 34 | ||||
| -rw-r--r-- | examples/core/core_scissor_test.png | bin | 0 -> 15348 bytes |
2 files changed, 14 insertions, 20 deletions
diff --git a/examples/core/core_scissor_test.c b/examples/core/core_scissor_test.c index acc84202..55221330 100644 --- a/examples/core/core_scissor_test.c +++ b/examples/core/core_scissor_test.c @@ -5,6 +5,8 @@ * This example has been created using raylib 2.5 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * +* Example contributed by Chris Dill (@MysteriousSpace) and reviewed by Ramon Santamaria (@raysan5) +* * Copyright (c) 2019 Chris Dill (@MysteriousSpace) * ********************************************************************************************/ @@ -20,10 +22,10 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [core] example - scissor test"); - Rectangle scissorArea = { 0, 0, 300, 300}; + Rectangle scissorArea = { 0, 0, 300, 300 }; bool scissorMode = true; - SetTargetFPS(60); + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -31,14 +33,11 @@ int main(void) { // Update //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_S)) - { - scissorMode = !scissorMode; - } + if (IsKeyPressed(KEY_S)) scissorMode = !scissorMode; // Centre the scissor area around the mouse position - scissorArea.x = GetMouseX() - scissorArea.width / 2; - scissorArea.y = GetMouseY() - scissorArea.height / 2; + scissorArea.x = GetMouseX() - scissorArea.width/2; + scissorArea.y = GetMouseY() - scissorArea.height/2; //---------------------------------------------------------------------------------- // Draw @@ -47,22 +46,17 @@ int main(void) ClearBackground(RAYWHITE); - if (scissorMode) - { - BeginScissorMode(scissorArea.x, scissorArea.y, scissorArea.width, scissorArea.height); - } + if (scissorMode) BeginScissorMode(scissorArea.x, scissorArea.y, scissorArea.width, scissorArea.height); - DrawRectangle(80, 45, 640, 360, RED); - DrawRectangleLines(80, 45, 640, 360, BLACK); + // Draw full screen rectangle and some text + // NOTE: Only part defined by scissor area will be rendered + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), RED); DrawText("Move the mouse around to reveal this text!", 190, 200, 20, LIGHTGRAY); - if (scissorMode) - { - EndScissorMode(); - } + if (scissorMode) EndScissorMode(); - DrawRectangleLinesEx(scissorArea, 2, BLACK); - DrawText("Press s to toggle scissor test", 10, 10, 20, DARKGRAY); + DrawRectangleLinesEx(scissorArea, 1, BLACK); + DrawText("Press S to toggle scissor test", 10, 10, 20, BLACK); EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/examples/core/core_scissor_test.png b/examples/core/core_scissor_test.png Binary files differnew file mode 100644 index 00000000..194872bb --- /dev/null +++ b/examples/core/core_scissor_test.png |
