diff options
| author | Ray <[email protected]> | 2019-05-21 17:03:01 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2019-05-21 17:03:01 +0200 |
| commit | 6f4a27cc61f12d3789729413bed69e86226911cf (patch) | |
| tree | 92a23884870826e6deaf560743ebbdae8bce94ba /examples/src/shapes | |
| parent | 2141d7943b6b65fa66f583f0819bb27fee815189 (diff) | |
| download | raylib.com-6f4a27cc61f12d3789729413bed69e86226911cf.tar.gz raylib.com-6f4a27cc61f12d3789729413bed69e86226911cf.zip | |
Remove examples default code
Code is directly fetched form raylib repo, this way we avoid duplicate code!
Diffstat (limited to 'examples/src/shapes')
| -rw-r--r-- | examples/src/shapes/shapes_basic_shapes.c | 73 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_bouncing_ball.c | 76 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_collision_area.c | 108 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_colors_palette.c | 99 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_draw_circle_sector.c | 81 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_draw_rectangle_rounded.c | 89 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_draw_ring.c | 94 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_easings_ball_anim.c | 110 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_easings_box_anim.c | 136 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_easings_rectangle_array.c | 118 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_following_eyes.c | 104 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_lines_bezier.c | 59 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_logo_raylib.c | 56 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_logo_raylib_anim.c | 160 | ||||
| -rw-r--r-- | examples/src/shapes/shapes_rectangle_scaling.c | 94 |
15 files changed, 0 insertions, 1457 deletions
diff --git a/examples/src/shapes/shapes_basic_shapes.c b/examples/src/shapes/shapes_basic_shapes.c deleted file mode 100644 index f7a8d02..0000000 --- a/examples/src/shapes/shapes_basic_shapes.c +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - Draw basic shapes 2d (rectangle, circle, line...) -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing"); - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY); - - DrawCircle(screenWidth/4, 120, 35, DARKBLUE); - - DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED); - DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE); // NOTE: Uses QUADS internally, not lines - DrawRectangleGradientH(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD); - - DrawTriangle((Vector2){screenWidth/4*3, 80}, - (Vector2){screenWidth/4*3 - 60, 150}, - (Vector2){screenWidth/4*3 + 60, 150}, VIOLET); - - DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN); - - DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE); - - // NOTE: We draw all LINES based shapes together to optimize internal drawing, - // this way, all LINES are rendered in a single draw pass - DrawLine(18, 42, screenWidth - 18, 42, BLACK); - DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE); - DrawTriangleLines((Vector2){screenWidth/4*3, 160}, - (Vector2){screenWidth/4*3 - 20, 230}, - (Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE); - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_bouncing_ball.c b/examples/src/shapes/shapes_bouncing_ball.c deleted file mode 100644 index 9f01ff1..0000000 --- a/examples/src/shapes/shapes_bouncing_ball.c +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - bouncing ball -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2013 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //--------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - bouncing ball"); - - Vector2 ballPosition = { GetScreenWidth()/2, GetScreenHeight()/2 }; - Vector2 ballSpeed = { 5.0f, 4.0f }; - int ballRadius = 20; - - bool pause = 0; - int framesCounter = 0; - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //---------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //----------------------------------------------------- - if (IsKeyPressed(KEY_SPACE)) pause = !pause; - - if (!pause) - { - ballPosition.x += ballSpeed.x; - ballPosition.y += ballSpeed.y; - - // Check walls collision for bouncing - if ((ballPosition.x >= (GetScreenWidth() - ballRadius)) || (ballPosition.x <= ballRadius)) ballSpeed.x *= -1.0f; - if ((ballPosition.y >= (GetScreenHeight() - ballRadius)) || (ballPosition.y <= ballRadius)) ballSpeed.y *= -1.0f; - } - else framesCounter++; - //----------------------------------------------------- - - // Draw - //----------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawCircleV(ballPosition, ballRadius, MAROON); - DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, LIGHTGRAY); - - // On pause, we draw a blinking message - if (pause && ((framesCounter/30)%2)) DrawText("PAUSED", 350, 200, 30, GRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //----------------------------------------------------- - } - - // De-Initialization - //--------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //---------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_collision_area.c b/examples/src/shapes/shapes_collision_area.c deleted file mode 100644 index 0deba0d..0000000 --- a/examples/src/shapes/shapes_collision_area.c +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - collision area -* -* 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) -* -* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include <stdlib.h> // Required for abs() - -int main(void) -{ - // Initialization - //--------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - collision area"); - - // Box A: Moving box - Rectangle boxA = { 10, GetScreenHeight()/2 - 50, 200, 100 }; - int boxASpeedX = 4; - - // Box B: Mouse moved box - Rectangle boxB = { GetScreenWidth()/2 - 30, GetScreenHeight()/2 - 30, 60, 60 }; - - Rectangle boxCollision = { 0 }; // Collision rectangle - - int screenUpperLimit = 40; // Top menu limits - - bool pause = false; // Movement pause - bool collision = false; // Collision detection - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //---------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //----------------------------------------------------- - // Move box if not paused - if (!pause) boxA.x += boxASpeedX; - - // Bounce box on x screen limits - if (((boxA.x + boxA.width) >= GetScreenWidth()) || (boxA.x <= 0)) boxASpeedX *= -1; - - // Update player-controlled-box (box02) - boxB.x = GetMouseX() - boxB.width/2; - boxB.y = GetMouseY() - boxB.height/2; - - // Make sure Box B does not go out of move area limits - if ((boxB.x + boxB.width) >= GetScreenWidth()) boxB.x = GetScreenWidth() - boxB.width; - else if (boxB.x <= 0) boxB.x = 0; - - if ((boxB.y + boxB.height) >= GetScreenHeight()) boxB.y = GetScreenHeight() - boxB.height; - else if (boxB.y <= screenUpperLimit) boxB.y = screenUpperLimit; - - // Check boxes collision - collision = CheckCollisionRecs(boxA, boxB); - - // Get collision rectangle (only on collision) - if (collision) boxCollision = GetCollisionRec(boxA, boxB); - - // Pause Box A movement - if (IsKeyPressed(KEY_SPACE)) pause = !pause; - //----------------------------------------------------- - - // Draw - //----------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectangle(0, 0, screenWidth, screenUpperLimit, collision? RED : BLACK); - - DrawRectangleRec(boxA, GOLD); - DrawRectangleRec(boxB, BLUE); - - if (collision) - { - // Draw collision area - DrawRectangleRec(boxCollision, LIME); - - // Draw collision message - DrawText("COLLISION!", GetScreenWidth()/2 - MeasureText("COLLISION!", 20)/2, screenUpperLimit/2 - 10, 20, BLACK); - - // Draw collision area - DrawText(FormatText("Collision Area: %i", (int)boxCollision.width*(int)boxCollision.height), GetScreenWidth()/2 - 100, screenUpperLimit + 10, 20, BLACK); - } - - DrawFPS(10, 10); - - EndDrawing(); - //----------------------------------------------------- - } - - // De-Initialization - //--------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //---------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_colors_palette.c b/examples/src/shapes/shapes_colors_palette.c deleted file mode 100644 index 7322f7e..0000000 --- a/examples/src/shapes/shapes_colors_palette.c +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - Colors palette -* -* 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) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_COLORS_COUNT 21 // Number of colors available - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - colors palette"); - - Color colors[MAX_COLORS_COUNT] = { - DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN, - GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW, - GREEN, SKYBLUE, PURPLE, BEIGE }; - - const char *colorNames[MAX_COLORS_COUNT] = { - "DARKGRAY", "MAROON", "ORANGE", "DARKGREEN", "DARKBLUE", "DARKPURPLE", - "DARKBROWN", "GRAY", "RED", "GOLD", "LIME", "BLUE", "VIOLET", "BROWN", - "LIGHTGRAY", "PINK", "YELLOW", "GREEN", "SKYBLUE", "PURPLE", "BEIGE" }; - - Rectangle colorsRecs[MAX_COLORS_COUNT] = { 0 }; // Rectangles array - - // Fills colorsRecs data (for every rectangle) - for (int i = 0; i < MAX_COLORS_COUNT; i++) - { - colorsRecs[i].x = 20 + 100*(i%7) + 10*(i%7); - colorsRecs[i].y = 80 + 100*(i/7) + 10*(i/7); - colorsRecs[i].width = 100; - colorsRecs[i].height = 100; - } - - int colorState[MAX_COLORS_COUNT] = { 0 }; // Color state: 0-DEFAULT, 1-MOUSE_HOVER - - Vector2 mousePoint; - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - mousePoint = GetMousePosition(); - - for (int i = 0; i < MAX_COLORS_COUNT; i++) - { - if (CheckCollisionPointRec(mousePoint, colorsRecs[i])) colorState[i] = 1; - else colorState[i] = 0; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("raylib colors palette", 28, 42, 20, BLACK); - DrawText("press SPACE to see all colors", GetScreenWidth() - 180, GetScreenHeight() - 40, 10, GRAY); - - for (int i = 0; i < MAX_COLORS_COUNT; i++) // Draw all rectangles - { - DrawRectangleRec(colorsRecs[i], Fade(colors[i], colorState[i]? 0.6f : 1.0f)); - - if (IsKeyDown(KEY_SPACE) || colorState[i]) - { - DrawRectangle(colorsRecs[i].x, colorsRecs[i].y + colorsRecs[i].height - 26, colorsRecs[i].width, 20, BLACK); - DrawRectangleLinesEx(colorsRecs[i], 6, Fade(BLACK, 0.3f)); - DrawText(colorNames[i], colorsRecs[i].x + colorsRecs[i].width - MeasureText(colorNames[i], 10) - 12, - colorsRecs[i].y + colorsRecs[i].height - 20, 10, colors[i]); - } - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_draw_circle_sector.c b/examples/src/shapes/shapes_draw_circle_sector.c deleted file mode 100644 index ae6de5f..0000000 --- a/examples/src/shapes/shapes_draw_circle_sector.c +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - draw circle sector (with gui options) -* -* 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 Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include <raylib.h> - -#define RAYGUI_IMPLEMENTATION -#include "raygui.h" // Required for GUI controls - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw circle sector"); - - Vector2 center = {(GetScreenWidth() - 300)/2, GetScreenHeight()/2 }; - - float outerRadius = 180.f; - int startAngle = 0; - int endAngle = 180; - int segments = 0; - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // NOTE: All variables update happens inside GUI control functions - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f)); - DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f)); - - DrawCircleSector(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3)); - DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.6)); - - // Draw GUI controls - //------------------------------------------------------------------------------ - startAngle = GuiSliderBar((Rectangle){ 600, 40, 120, 20}, "StartAngle", startAngle, 0, 720, true ); - endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", endAngle, 0, 720, true); - - outerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", outerRadius, 0, 200, true); - segments = GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", segments, 0, 100, true); - //------------------------------------------------------------------------------ - - DrawText(FormatText("MODE: %s", (segments >= 4)? "MANUAL" : "AUTO"), 600, 200, 10, (segments >= 4)? MAROON : DARKGRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_draw_rectangle_rounded.c b/examples/src/shapes/shapes_draw_rectangle_rounded.c deleted file mode 100644 index c183e88..0000000 --- a/examples/src/shapes/shapes_draw_rectangle_rounded.c +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - draw rectangle rounded (with gui options) -* -* 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 Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include <raylib.h> - -#define RAYGUI_IMPLEMENTATION -#include "raygui.h" // Required for GUI controls - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw rectangle rounded"); - - float roundness = 0.2f; - int width = 200; - int height = 100; - int segments = 0; - int lineThick = 1; - - bool drawRect = false; - bool drawRoundedRect = true; - bool drawRoundedLines = false; - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - Rectangle rec = { (GetScreenWidth() - width - 250)/2, (GetScreenHeight() - height)/2, width, height }; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawLine(560, 0, 560, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f)); - DrawRectangle(560, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f)); - - if (drawRect) DrawRectangleRec(rec, Fade(GOLD, 0.6)); - if (drawRoundedRect) DrawRectangleRounded(rec, roundness, segments, Fade(MAROON, 0.2)); - if (drawRoundedLines) DrawRectangleRoundedLines(rec,roundness, segments, lineThick, Fade(MAROON, 0.4)); - - // Draw GUI controls - //------------------------------------------------------------------------------ - width = GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", width, 0, GetScreenWidth() - 300, true ); - height = GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", height, 0, GetScreenHeight() - 50, true); - roundness = GuiSliderBar((Rectangle){ 640, 140, 105, 20 }, "Roundness", roundness, 0.0f, 1.0f, true); - lineThick = GuiSliderBar((Rectangle){ 640, 170, 105, 20 }, "Thickness", lineThick, 0, 20, true); - segments = GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", segments, 0, 60, true); - - drawRoundedRect = GuiCheckBox((Rectangle){ 640, 320, 20, 20 }, "DrawRoundedRect", drawRoundedRect); - drawRoundedLines = GuiCheckBox((Rectangle){ 640, 350, 20, 20 }, "DrawRoundedLines", drawRoundedLines); - drawRect = GuiCheckBox((Rectangle){ 640, 380, 20, 20}, "DrawRect", drawRect); - //------------------------------------------------------------------------------ - - DrawText(FormatText("MODE: %s", (segments >= 4)? "MANUAL" : "AUTO"), 640, 280, 10, (segments >= 4)? MAROON : DARKGRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/shapes/shapes_draw_ring.c b/examples/src/shapes/shapes_draw_ring.c deleted file mode 100644 index a90feab..0000000 --- a/examples/src/shapes/shapes_draw_ring.c +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - draw ring (with gui options) -* -* 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 Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include <raylib.h> - -#define RAYGUI_IMPLEMENTATION -#include "raygui.h" // Required for GUI controls - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw ring"); - - Vector2 center = {(GetScreenWidth() - 300)/2, GetScreenHeight()/2 }; - - float innerRadius = 80.0f; - float outerRadius = 190.0f; - - int startAngle = 0; - int endAngle = 360; - int segments = 0; - - bool drawRing = true; - bool drawRingLines = false; - bool drawCircleLines = false; - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // NOTE: All variables update happens inside GUI control functions - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f)); - DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f)); - - if (drawRing) DrawRing(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3)); - if (drawRingLines) DrawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4)); - if (drawCircleLines) DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4)); - - // Draw GUI controls - //------------------------------------------------------------------------------ - startAngle = GuiSliderBar((Rectangle){ 600, 40, 120, 20 }, "StartAngle", startAngle, -450, 450, true); - endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20 }, "EndAngle", endAngle, -450, 450, true); - - innerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20 }, "InnerRadius", innerRadius, 0, 100, true); - outerRadius = GuiSliderBar((Rectangle){ 600, 170, 120, 20 }, "OuterRadius", outerRadius, 0, 200, true); - - segments = GuiSliderBar((Rectangle){ 600, 240, 120, 20 }, "Segments", segments, 0, 100, true); - - drawRing = GuiCheckBox((Rectangle){ 600, 320, 20, 20 }, "Draw Ring", drawRing); - drawRingLines = GuiCheckBox((Rectangle){ 600, 350, 20, 20 }, "Draw RingLines", drawRingLines); - drawCircleLines = GuiCheckBox((Rectangle){ 600, 380, 20, 20 }, "Draw CircleLines", drawCircleLines); - //------------------------------------------------------------------------------ - - DrawText(FormatText("MODE: %s", (segments >= 4)? "MANUAL" : "AUTO"), 600, 270, 10, (segments >= 4)? MAROON : DARKGRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_easings_ball_anim.c b/examples/src/shapes/shapes_easings_ball_anim.c deleted file mode 100644 index 5bb2b4c..0000000 --- a/examples/src/shapes/shapes_easings_ball_anim.c +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - easings ball anim -* -* 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) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include "easings.h" // Required for easing functions - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings ball anim"); - - // Ball variable value to be animated with easings - int ballPositionX = -100; - int ballRadius = 20; - float ballAlpha = 0.0f; - - int state = 0; - int framesCounter = 0; - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - if (state == 0) // Move ball position X with easing - { - framesCounter++; - ballPositionX = EaseElasticOut(framesCounter, -100, screenWidth/2 + 100, 120); - - if (framesCounter >= 120) - { - framesCounter = 0; - state = 1; - } - } - else if (state == 1) // Increase ball radius with easing - { - framesCounter++; - ballRadius = EaseElasticIn(framesCounter, 20, 500, 200); - - if (framesCounter >= 200) - { - framesCounter = 0; - state = 2; - } - } - else if (state == 2) // Change ball alpha with easing (background color blending) - { - framesCounter++; - ballAlpha = EaseCubicOut(framesCounter, 0.0f, 1.0f, 200); - - if (framesCounter >= 200) - { - framesCounter = 0; - state = 3; - } - } - else if (state == 3) // Reset state to play again - { - if (IsKeyPressed(KEY_ENTER)) - { - // Reset required variables to play again - ballPositionX = -100; - ballRadius = 20; - ballAlpha = 0.0f; - state = 0; - } - } - - if (IsKeyPressed(KEY_R)) framesCounter = 0; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (state >= 2) DrawRectangle(0, 0, screenWidth, screenHeight, GREEN); - DrawCircle(ballPositionX, 200, ballRadius, Fade(RED, 1.0f - ballAlpha)); - - if (state == 3) DrawText("PRESS [ENTER] TO PLAY AGAIN!", 240, 200, 20, BLACK); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_easings_box_anim.c b/examples/src/shapes/shapes_easings_box_anim.c deleted file mode 100644 index 6805d53..0000000 --- a/examples/src/shapes/shapes_easings_box_anim.c +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - easings box anim -* -* 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) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include "easings.h" // Required for easing functions - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings box anim"); - - // Box variables to be animated with easings - Rectangle rec = { GetScreenWidth()/2, -100, 100, 100 }; - float rotation = 0.0f; - float alpha = 1.0f; - - int state = 0; - int framesCounter = 0; - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - switch (state) - { - case 0: // Move box down to center of screen - { - framesCounter++; - - // NOTE: Remember that 3rd parameter of easing function refers to - // desired value variation, do not confuse it with expected final value! - rec.y = EaseElasticOut(framesCounter, -100, GetScreenHeight()/2 + 100, 120); - - if (framesCounter >= 120) - { - framesCounter = 0; - state = 1; - } - } break; - case 1: // Scale box to an horizontal bar - { - framesCounter++; - rec.height = EaseBounceOut(framesCounter, 100, -90, 120); - rec.width = EaseBounceOut(framesCounter, 100, GetScreenWidth(), 120); - - if (framesCounter >= 120) - { - framesCounter = 0; - state = 2; - } - } break; - case 2: // Rotate horizontal bar rectangle - { - framesCounter++; - rotation = EaseQuadOut(framesCounter, 0.0f, 270.0f, 240); - - if (framesCounter >= 240) - { - framesCounter = 0; - state = 3; - } - } break; - case 3: // Increase bar size to fill all screen - { - framesCounter++; - rec.height = EaseCircOut(framesCounter, 10, GetScreenWidth(), 120); - - if (framesCounter >= 120) - { - framesCounter = 0; - state = 4; - } - } break; - case 4: // Fade out animation - { - framesCounter++; - alpha = EaseSineOut(framesCounter, 1.0f, -1.0f, 160); - - if (framesCounter >= 160) - { - framesCounter = 0; - state = 5; - } - } break; - default: break; - } - - // Reset animation at any moment - if (IsKeyPressed(KEY_SPACE)) - { - rec = (Rectangle){ GetScreenWidth()/2, -100, 100, 100 }; - rotation = 0.0f; - alpha = 1.0f; - state = 0; - framesCounter = 0; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectanglePro(rec, (Vector2){ rec.width/2, rec.height/2 }, rotation, Fade(BLACK, alpha)); - - DrawText("PRESS [SPACE] TO RESET BOX ANIMATION!", 10, GetScreenHeight() - 25, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_easings_rectangle_array.c b/examples/src/shapes/shapes_easings_rectangle_array.c deleted file mode 100644 index 9844af6..0000000 --- a/examples/src/shapes/shapes_easings_rectangle_array.c +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - easings rectangle array -* -* NOTE: This example requires 'easings.h' library, provided on raylib/src. Just copy -* the library to same directory as example or make sure it's available on include path. -* -* This example has been created using raylib 2.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include "easings.h" // Required for easing functions - -#define RECS_WIDTH 50 -#define RECS_HEIGHT 50 - -#define MAX_RECS_X 800/RECS_WIDTH -#define MAX_RECS_Y 450/RECS_HEIGHT - -#define PLAY_TIME_IN_FRAMES 240 // At 60 fps = 4 seconds - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings rectangle array"); - - Rectangle recs[MAX_RECS_X*MAX_RECS_Y]; - - for (int y = 0; y < MAX_RECS_Y; y++) - { - for (int x = 0; x < MAX_RECS_X; x++) - { - recs[y*MAX_RECS_X + x].x = RECS_WIDTH/2 + RECS_WIDTH*x; - recs[y*MAX_RECS_X + x].y = RECS_HEIGHT/2 + RECS_HEIGHT*y; - recs[y*MAX_RECS_X + x].width = RECS_WIDTH; - recs[y*MAX_RECS_X + x].height = RECS_HEIGHT; - } - } - - float rotation = 0.0f; - int framesCounter = 0; - int state = 0; // Rectangles animation state: 0-Playing, 1-Finished - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - if (state == 0) - { - framesCounter++; - - for (int i = 0; i < MAX_RECS_X*MAX_RECS_Y; i++) - { - recs[i].height = EaseCircOut(framesCounter, RECS_HEIGHT, -RECS_HEIGHT, PLAY_TIME_IN_FRAMES); - recs[i].width = EaseCircOut(framesCounter, RECS_WIDTH, -RECS_WIDTH, PLAY_TIME_IN_FRAMES); - - if (recs[i].height < 0) recs[i].height = 0; - if (recs[i].width < 0) recs[i].width = 0; - - if ((recs[i].height == 0) && (recs[i].width == 0)) state = 1; // Finish playing - - rotation = EaseLinearIn(framesCounter, 0.0f, 360.0f, PLAY_TIME_IN_FRAMES); - } - } - else if ((state == 1) && IsKeyPressed(KEY_SPACE)) - { - // When animation has finished, press space to restart - framesCounter = 0; - - for (int i = 0; i < MAX_RECS_X*MAX_RECS_Y; i++) - { - recs[i].height = RECS_HEIGHT; - recs[i].width = RECS_WIDTH; - } - - state = 0; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (state == 0) - { - for (int i = 0; i < MAX_RECS_X*MAX_RECS_Y; i++) - { - DrawRectanglePro(recs[i], (Vector2){ recs[i].width/2, recs[i].height/2 }, rotation, RED); - } - } - else if (state == 1) DrawText("PRESS [SPACE] TO PLAY AGAIN!", 240, 200, 20, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_following_eyes.c b/examples/src/shapes/shapes_following_eyes.c deleted file mode 100644 index a36a8d6..0000000 --- a/examples/src/shapes/shapes_following_eyes.c +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - following eyes -* -* 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) -* -* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <math.h> // Required for: atan2f() - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - following eyes"); - - Vector2 scleraLeftPosition = { GetScreenWidth()/2 - 100, GetScreenHeight()/2 }; - Vector2 scleraRightPosition = { GetScreenWidth()/2 + 100, GetScreenHeight()/2 }; - float scleraRadius = 80; - - Vector2 irisLeftPosition = { GetScreenWidth()/2 - 100, GetScreenHeight()/2 }; - Vector2 irisRightPosition = { GetScreenWidth()/2 + 100, GetScreenHeight()/2}; - float irisRadius = 24; - - float angle = 0.0f; - float dx = 0.0f, dy = 0.0f, dxx = 0.0f, dyy = 0.0f; - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - irisLeftPosition = GetMousePosition(); - irisRightPosition = GetMousePosition(); - - // Check not inside the left eye sclera - if (!CheckCollisionPointCircle(irisLeftPosition, scleraLeftPosition, scleraRadius - 20)) - { - dx = irisLeftPosition.x - scleraLeftPosition.x; - dy = irisLeftPosition.y - scleraLeftPosition.y; - - angle = atan2f(dy, dx); - - dxx = (scleraRadius - irisRadius)*cosf(angle); - dyy = (scleraRadius - irisRadius)*sinf(angle); - - irisLeftPosition.x = scleraLeftPosition.x + dxx; - irisLeftPosition.y = scleraLeftPosition.y + dyy; - } - - // Check not inside the right eye sclera - if (!CheckCollisionPointCircle(irisRightPosition, scleraRightPosition, scleraRadius - 20)) - { - dx = irisRightPosition.x - scleraRightPosition.x; - dy = irisRightPosition.y - scleraRightPosition.y; - - angle = atan2f(dy, dx); - - dxx = (scleraRadius - irisRadius)*cosf(angle); - dyy = (scleraRadius - irisRadius)*sinf(angle); - - irisRightPosition.x = scleraRightPosition.x + dxx; - irisRightPosition.y = scleraRightPosition.y + dyy; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawCircleV(scleraLeftPosition, scleraRadius, LIGHTGRAY); - DrawCircleV(irisLeftPosition, irisRadius, BROWN); - DrawCircleV(irisLeftPosition, 10, BLACK); - - DrawCircleV(scleraRightPosition, scleraRadius, LIGHTGRAY); - DrawCircleV(irisRightPosition, irisRadius, DARKGREEN); - DrawCircleV(irisRightPosition, 10, BLACK); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_lines_bezier.c b/examples/src/shapes/shapes_lines_bezier.c deleted file mode 100644 index 3d4edcd..0000000 --- a/examples/src/shapes/shapes_lines_bezier.c +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - Cubic-bezier lines -* -* This example has been created using raylib 1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2017 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines"); - - Vector2 start = { 0, 0 }; - Vector2 end = { screenWidth, screenHeight }; - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) start = GetMousePosition(); - else if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) end = GetMousePosition(); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, GRAY); - - DrawLineBezier(start, end, 2.0f, RED); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/shapes/shapes_logo_raylib.c b/examples/src/shapes/shapes_logo_raylib.c deleted file mode 100644 index 3e2d343..0000000 --- a/examples/src/shapes/shapes_logo_raylib.c +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - Draw raylib logo using basic shapes -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes"); - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK); - DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, RAYWHITE); - DrawText("raylib", screenWidth/2 - 44, screenHeight/2 + 48, 50, BLACK); - - DrawText("this is NOT a texture!", 350, 370, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_logo_raylib_anim.c b/examples/src/shapes/shapes_logo_raylib_anim.c deleted file mode 100644 index b855839..0000000 --- a/examples/src/shapes/shapes_logo_raylib_anim.c +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - raylib logo animation -* -* This example has been created using raylib 2.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo animation"); - - int logoPositionX = screenWidth/2 - 128; - int logoPositionY = screenHeight/2 - 128; - - int framesCounter = 0; - int lettersCount = 0; - - int topSideRecWidth = 16; - int leftSideRecHeight = 16; - - int bottomSideRecWidth = 16; - int rightSideRecHeight = 16; - - int state = 0; // Tracking animation states (State Machine) - float alpha = 1.0f; // Useful for fading - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - if (state == 0) // State 0: Small box blinking - { - framesCounter++; - - if (framesCounter == 120) - { - state = 1; - framesCounter = 0; // Reset counter... will be used later... - } - } - else if (state == 1) // State 1: Top and left bars growing - { - topSideRecWidth += 4; - leftSideRecHeight += 4; - - if (topSideRecWidth == 256) state = 2; - } - else if (state == 2) // State 2: Bottom and right bars growing - { - bottomSideRecWidth += 4; - rightSideRecHeight += 4; - - if (bottomSideRecWidth == 256) state = 3; - } - else if (state == 3) // State 3: Letters appearing (one by one) - { - framesCounter++; - - if (framesCounter/12) // Every 12 frames, one more letter! - { - lettersCount++; - framesCounter = 0; - } - - if (lettersCount >= 10) // When all letters have appeared, just fade out everything - { - alpha -= 0.02f; - - if (alpha <= 0.0f) - { - alpha = 0.0f; - state = 4; - } - } - } - else if (state == 4) // State 4: Reset and Replay - { - if (IsKeyPressed('R')) - { - framesCounter = 0; - lettersCount = 0; - - topSideRecWidth = 16; - leftSideRecHeight = 16; - - bottomSideRecWidth = 16; - rightSideRecHeight = 16; - - alpha = 1.0f; - state = 0; // Return to State 0 - } - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (state == 0) - { - if ((framesCounter/15)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK); - } - else if (state == 1) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - } - else if (state == 2) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK); - } - else if (state == 3) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(TextSubtext("raylib", 0, lettersCount), screenWidth/2 - 44, screenHeight/2 + 48, 50, Fade(BLACK, alpha)); - } - else if (state == 4) - { - DrawText("[R] REPLAY", 340, 200, 20, GRAY); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_rectangle_scaling.c b/examples/src/shapes/shapes_rectangle_scaling.c deleted file mode 100644 index 6940cbc..0000000 --- a/examples/src/shapes/shapes_rectangle_scaling.c +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - rectangle scaling by mouse -* -* 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 Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MOUSE_SCALE_MARK_SIZE 12 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - 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); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - mousePosition = GetMousePosition(); - - 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; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Scale rectangle dragging from bottom-right corner!", 10, 10, 20, GRAY); - - DrawRectangleRec(rec, Fade(GREEN, 0.5f)); - - if (mouseScaleReady) - { - DrawRectangleLinesEx(rec, 1, RED); - 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); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file |
