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/core | |
| 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/core')
20 files changed, 0 insertions, 1880 deletions
diff --git a/examples/src/core/core_2d_camera.c b/examples/src/core/core_2d_camera.c deleted file mode 100644 index fe8e584..0000000 --- a/examples/src/core/core_2d_camera.c +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - 2d camera -* -* This example has been created using raylib 1.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_BUILDINGS 100 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera"); - - Rectangle player = { 400, 280, 40, 40 }; - Rectangle buildings[MAX_BUILDINGS]; - Color buildColors[MAX_BUILDINGS]; - - int spacing = 0; - - for (int i = 0; i < MAX_BUILDINGS; i++) - { - buildings[i].width = GetRandomValue(50, 200); - buildings[i].height = GetRandomValue(100, 800); - buildings[i].y = screenHeight - 130 - buildings[i].height; - buildings[i].x = -6000 + spacing; - - spacing += buildings[i].width; - - buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 }; - } - - Camera2D camera = { 0 }; - - camera.target = (Vector2){ player.x + 20, player.y + 20 }; - camera.offset = (Vector2){ 0, 0 }; - camera.rotation = 0.0f; - camera.zoom = 1.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 - //---------------------------------------------------------------------------------- - if (IsKeyDown(KEY_RIGHT)) - { - player.x += 2; // Player movement - camera.offset.x -= 2; // Camera displacement with player movement - } - else if (IsKeyDown(KEY_LEFT)) - { - player.x -= 2; // Player movement - camera.offset.x += 2; // Camera displacement with player movement - } - - // Camera target follows player - camera.target = (Vector2){ player.x + 20, player.y + 20 }; - - // Camera rotation controls - if (IsKeyDown(KEY_A)) camera.rotation--; - else if (IsKeyDown(KEY_S)) camera.rotation++; - - // Limit camera rotation to 80 degrees (-40 to 40) - if (camera.rotation > 40) camera.rotation = 40; - else if (camera.rotation < -40) camera.rotation = -40; - - // Camera zoom controls - camera.zoom += ((float)GetMouseWheelMove()*0.05f); - - if (camera.zoom > 3.0f) camera.zoom = 3.0f; - else if (camera.zoom < 0.1f) camera.zoom = 0.1f; - - // Camera reset (zoom and rotation) - if (IsKeyPressed(KEY_R)) - { - camera.zoom = 1.0f; - camera.rotation = 0.0f; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode2D(camera); - - DrawRectangle(-6000, 320, 13000, 8000, DARKGRAY); - - for (int i = 0; i < MAX_BUILDINGS; i++) DrawRectangleRec(buildings[i], buildColors[i]); - - DrawRectangleRec(player, RED); - - DrawLine(camera.target.x, -screenHeight*10, camera.target.x, screenHeight*10, GREEN); - DrawLine(-screenWidth*10, camera.target.y, screenWidth*10, camera.target.y, GREEN); - - EndMode2D(); - - DrawText("SCREEN AREA", 640, 10, 20, RED); - - DrawRectangle(0, 0, screenWidth, 5, RED); - DrawRectangle(0, 5, 5, screenHeight - 10, RED); - DrawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, RED); - DrawRectangle(0, screenHeight - 5, screenWidth, 5, RED); - - DrawRectangle( 10, 10, 250, 113, Fade(SKYBLUE, 0.5f)); - DrawRectangleLines( 10, 10, 250, 113, BLUE); - - DrawText("Free 2d camera controls:", 20, 20, 10, BLACK); - DrawText("- Right/Left to move Offset", 40, 40, 10, DARKGRAY); - DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY); - DrawText("- A / S to Rotate", 40, 80, 10, DARKGRAY); - DrawText("- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_3d_camera_first_person.c b/examples/src/core/core_3d_camera_first_person.c deleted file mode 100644 index 825a9ca..0000000 --- a/examples/src/core/core_3d_camera_first_person.c +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - 3d camera first person -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_COLUMNS 20 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person"); - - // Define the camera to look into our 3d world (position, target, up vector) - Camera camera = { 0 }; - camera.position = (Vector3){ 4.0f, 2.0f, 4.0f }; - camera.target = (Vector3){ 0.0f, 1.8f, 0.0f }; - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - camera.fovy = 60.0f; - camera.type = CAMERA_PERSPECTIVE; - - // Generates some random columns - float heights[MAX_COLUMNS]; - Vector3 positions[MAX_COLUMNS]; - Color colors[MAX_COLUMNS]; - - for (int i = 0; i < MAX_COLUMNS; i++) - { - heights[i] = (float)GetRandomValue(1, 12); - positions[i] = (Vector3){ GetRandomValue(-15, 15), heights[i]/2, GetRandomValue(-15, 15) }; - colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 }; - } - - SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person camera mode - - 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 - //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update camera - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawPlane((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector2){ 32.0f, 32.0f }, LIGHTGRAY); // Draw ground - DrawCube((Vector3){ -16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, BLUE); // Draw a blue wall - DrawCube((Vector3){ 16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, LIME); // Draw a green wall - DrawCube((Vector3){ 0.0f, 2.5f, 16.0f }, 32.0f, 5.0f, 1.0f, GOLD); // Draw a yellow wall - - // Draw some cubes around - for (int i = 0; i < MAX_COLUMNS; i++) - { - DrawCube(positions[i], 2.0f, heights[i], 2.0f, colors[i]); - DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, MAROON); - } - - EndMode3D(); - - DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f)); - DrawRectangleLines( 10, 10, 220, 70, BLUE); - - DrawText("First person camera default controls:", 20, 20, 10, BLACK); - DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY); - DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_3d_camera_free.c b/examples/src/core/core_3d_camera_free.c deleted file mode 100644 index c1445f6..0000000 --- a/examples/src/core/core_3d_camera_free.c +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Initialize 3d camera free -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); - - // Define the camera to look into our 3d world - Camera3D camera; - camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera mode type - - Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; - - SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode - - 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 - //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update camera - - if (IsKeyDown('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); - DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); - - DrawGrid(10, 1.0f); - - EndMode3D(); - - DrawRectangle( 10, 10, 320, 133, Fade(SKYBLUE, 0.5f)); - DrawRectangleLines( 10, 10, 320, 133, BLUE); - - DrawText("Free camera default controls:", 20, 20, 10, BLACK); - DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY); - DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY); - DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, DARKGRAY); - DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, DARKGRAY); - DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_3d_camera_mode.c b/examples/src/core/core_3d_camera_mode.c deleted file mode 100644 index eae6c88..0000000 --- a/examples/src/core/core_3d_camera_mode.c +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Initialize 3d camera mode -* -* 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 [core] example - 3d camera mode"); - - // Define the camera to look into our 3d world - Camera3D camera = { 0 }; - camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera mode type - - Vector3 cubePosition = { 0.0f, 0.0f, 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 - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); - DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); - - DrawGrid(10, 1.0f); - - EndMode3D(); - - DrawText("Welcome to the third dimension!", 10, 40, 20, 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/core/core_3d_picking.c b/examples/src/core/core_3d_picking.c deleted file mode 100644 index 1e60c03..0000000 --- a/examples/src/core/core_3d_picking.c +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Picking in 3d mode -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking"); - - // Define the camera to look into our 3d world - Camera camera; - camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera mode type - - Vector3 cubePosition = { 0.0f, 1.0f, 0.0f }; - Vector3 cubeSize = { 2.0f, 2.0f, 2.0f }; - - Ray ray = {0.0f, 0.0f, 0.0f}; // Picking line ray - - bool collision = false; - - SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode - - 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 - //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update camera - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - ray = GetMouseRay(GetMousePosition(), camera); - - // Check collision between ray and box - collision = CheckCollisionRayBox(ray, - (BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 }, - (Vector3){ cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2 }}); - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - if (collision) - { - DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED); - DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON); - - DrawCubeWires(cubePosition, cubeSize.x + 0.2f, cubeSize.y + 0.2f, cubeSize.z + 0.2f, GREEN); - } - else - { - DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY); - DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY); - } - - DrawRay(ray, MAROON); - DrawGrid(10, 1.0f); - - EndMode3D(); - - DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY); - - if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/core/core_basic_window.c b/examples/src/core/core_basic_window.c deleted file mode 100644 index 3c103a5..0000000 --- a/examples/src/core/core_basic_window.c +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Basic window -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* 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-2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); - - 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("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_custom_logging.c b/examples/src/core/core_custom_logging.c deleted file mode 100644 index 0ab3fa4..0000000 --- a/examples/src/core/core_custom_logging.c +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Custom logging -* -* This example has been created using raylib 2.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Pablo Marcos Oltra (@pamarcos) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Pablo Marcos Oltra (@pamarcos) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <stdio.h> // Required for: fopen(), fclose(), fputc(), fwrite(), printf(), fprintf(), funopen() -#include <time.h> // Required for: time_t, tm, time(), localtime(), strftime() - -// Custom logging funtion -void LogCustom(int msgType, const char *text, va_list args) -{ - char timeStr[64]; - time_t now = time(NULL); - struct tm *tm_info = localtime(&now); - - strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S", tm_info); - printf("[%s] ", timeStr); - - switch (msgType) - { - case LOG_INFO: printf("[INFO] : "); break; - case LOG_ERROR: printf("[ERROR]: "); break; - case LOG_WARNING: printf("[WARN] : "); break; - case LOG_DEBUG: printf("[DEBUG]: "); break; - default: break; - } - - vprintf(text, args); - printf("\n"); -} - -int main(int argc, char* argv[]) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - // First thing we do is setting our custom logger to ensure everything raylib logs - // will use our own logger instead of its internal one - SetTraceLogCallback(LogCustom); - - InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging"); - - 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("Check out the console output to see the custom logger in action!", 60, 200, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/core/core_drop_files.c b/examples/src/core/core_drop_files.c deleted file mode 100644 index 5c3af6a..0000000 --- a/examples/src/core/core_drop_files.c +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Windows drop files -* -* This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?) -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files"); - - int count = 0; - char **droppedFiles = { 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 (IsFileDropped()) - { - droppedFiles = GetDroppedFiles(&count); - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (count == 0) DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY); - else - { - DrawText("Dropped files:", 100, 40, 20, DARKGRAY); - - for (int i = 0; i < count; i++) - { - if (i%2 == 0) DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f)); - else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f)); - - DrawText(droppedFiles[i], 120, 100 + 40*i, 10, GRAY); - } - - DrawText("Drop new files...", 100, 110 + 40*count, 20, DARKGRAY); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClearDroppedFiles(); // Clear internal buffers - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_input_gamepad.c b/examples/src/core/core_input_gamepad.c deleted file mode 100644 index 51646aa..0000000 --- a/examples/src/core/core_input_gamepad.c +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Gamepad input -* -* NOTE: This example requires a Gamepad connected to the system -* raylib is configured to work with the following gamepads: -* - Xbox 360 Controller (Xbox 360, Xbox One) -* - PLAYSTATION(R)3 Controller -* Check raylib.h for buttons configuration -* -* 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" - -// NOTE: Gamepad name ID depends on drivers and OS -#if defined(PLATFORM_RPI) - #define XBOX360_NAME_ID "Microsoft X-Box 360 pad" - #define PS3_NAME_ID "PLAYSTATION(R)3 Controller" -#else - #define XBOX360_NAME_ID "Xbox 360 Controller" - #define PS3_NAME_ID "PLAYSTATION(R)3 Controller" -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation - - InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input"); - - Texture2D texPs3Pad = LoadTexture("resources/ps3.png"); - Texture2D texXboxPad = LoadTexture("resources/xbox.png"); - - 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 - //---------------------------------------------------------------------------------- - // ... - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (IsGamepadAvailable(GAMEPAD_PLAYER1)) - { - DrawText(FormatText("GP1: %s", GetGamepadName(GAMEPAD_PLAYER1)), 10, 10, 10, BLACK); - - if (IsGamepadName(GAMEPAD_PLAYER1, XBOX360_NAME_ID)) - { - DrawTexture(texXboxPad, 0, 0, DARKGRAY); - - // Draw buttons: xbox home - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(394, 89, 19, RED); - - // Draw buttons: basic - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawCircle(436, 150, 9, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawCircle(352, 150, 9, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(501, 151, 15, BLUE); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(536, 187, 15, LIME); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(572, 151, 15, MAROON); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(536, 115, 15, GOLD); - - // Draw buttons: d-pad - DrawRectangle(317, 202, 19, 71, BLACK); - DrawRectangle(293, 228, 69, 19, BLACK); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(317, 202, 19, 26, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(317, 202 + 45, 19, 26, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(292, 228, 25, 19, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(292 + 44, 228, 26, 19, RED); - - // Draw buttons: left-right back - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(259, 61, 20, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(536, 61, 20, RED); - - // Draw axis: left joystick - DrawCircle(259, 152, 39, BLACK); - DrawCircle(259, 152, 34, LIGHTGRAY); - DrawCircle(259 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_X)*20), - 152 - (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_Y)*20), 25, BLACK); - - // Draw axis: right joystick - DrawCircle(461, 237, 38, BLACK); - DrawCircle(461, 237, 33, LIGHTGRAY); - DrawCircle(461 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_X)*20), - 237 - (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_Y)*20), 25, BLACK); - - // Draw axis: left-right triggers - DrawRectangle(170, 30, 15, 70, GRAY); - DrawRectangle(604, 30, 15, 70, GRAY); - DrawRectangle(170, 30, 15, (((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_TRIGGER))/2.0f)*70), RED); - DrawRectangle(604, 30, 15, (((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_TRIGGER))/2.0f)*70), RED); - - //DrawText(FormatText("Xbox axis LT: %02.02f", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_TRIGGER)), 10, 40, 10, BLACK); - //DrawText(FormatText("Xbox axis RT: %02.02f", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK); - } - else if (IsGamepadName(GAMEPAD_PLAYER1, PS3_NAME_ID)) - { - DrawTexture(texPs3Pad, 0, 0, DARKGRAY); - - // Draw buttons: ps - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(396, 222, 13, RED); - - // Draw buttons: basic - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawRectangle(328, 170, 32, 13, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawTriangle((Vector2){ 436, 168 }, (Vector2){ 436, 185 }, (Vector2){ 464, 177 }, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(557, 144, 13, LIME); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(586, 173, 13, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(557, 203, 13, VIOLET); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(527, 173, 13, PINK); - - // Draw buttons: d-pad - DrawRectangle(225, 132, 24, 84, BLACK); - DrawRectangle(195, 161, 84, 25, BLACK); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_UP)) DrawRectangle(225, 132, 24, 29, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(225, 132 + 54, 24, 30, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(195, 161, 30, 25, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(195 + 54, 161, 30, 25, RED); - - // Draw buttons: left-right back buttons - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(239, 82, 20, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(557, 82, 20, RED); - - // Draw axis: left joystick - DrawCircle(319, 255, 35, BLACK); - DrawCircle(319, 255, 31, LIGHTGRAY); - DrawCircle(319 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_X)*20), - 255 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_Y)*20), 25, BLACK); - - // Draw axis: right joystick - DrawCircle(475, 255, 35, BLACK); - DrawCircle(475, 255, 31, LIGHTGRAY); - DrawCircle(475 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_X)*20), - 255 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_Y)*20), 25, BLACK); - - // Draw axis: left-right triggers - DrawRectangle(169, 48, 15, 70, GRAY); - DrawRectangle(611, 48, 15, 70, GRAY); - DrawRectangle(169, 48, 15, (((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_TRIGGER))/2.0f)*70), RED); - DrawRectangle(611, 48, 15, (((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_TRIGGER))/2.0f)*70), RED); - } - else - { - DrawText("- GENERIC GAMEPAD -", 280, 180, 20, GRAY); - - // TODO: Draw generic gamepad - } - - DrawText(FormatText("DETECTED AXIS [%i]:", GetGamepadAxisCount(GAMEPAD_PLAYER1)), 10, 50, 10, MAROON); - - for (int i = 0; i < GetGamepadAxisCount(GAMEPAD_PLAYER1); i++) - { - DrawText(FormatText("AXIS %i: %.02f", i, GetGamepadAxisMovement(GAMEPAD_PLAYER1, i)), 20, 70 + 20*i, 10, DARKGRAY); - } - - if (GetGamepadButtonPressed() != -1) DrawText(FormatText("DETECTED BUTTON: %i", GetGamepadButtonPressed()), 10, 430, 10, RED); - else DrawText("DETECTED BUTTON: NONE", 10, 430, 10, GRAY); - } - else - { - DrawText("GP1: NOT DETECTED", 10, 10, 10, GRAY); - - DrawTexture(texXboxPad, 0, 0, LIGHTGRAY); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(texPs3Pad); - UnloadTexture(texXboxPad); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_input_gestures.c b/examples/src/core/core_input_gestures.c deleted file mode 100644 index affab3e..0000000 --- a/examples/src/core/core_input_gestures.c +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Input Gestures Detection -* -* This example has been created using raylib 1.4 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include <string.h> - -#define MAX_GESTURE_STRINGS 20 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures"); - - Vector2 touchPosition = { 0, 0 }; - Rectangle touchArea = { 220, 10, screenWidth - 230, screenHeight - 20 }; - - int gesturesCount = 0; - char gestureStrings[MAX_GESTURE_STRINGS][32]; - - int currentGesture = GESTURE_NONE; - int lastGesture = GESTURE_NONE; - - //SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected - - 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 - //---------------------------------------------------------------------------------- - lastGesture = currentGesture; - currentGesture = GetGestureDetected(); - touchPosition = GetTouchPosition(0); - - if (CheckCollisionPointRec(touchPosition, touchArea) && (currentGesture != GESTURE_NONE)) - { - if (currentGesture != lastGesture) - { - // Store gesture string - switch (currentGesture) - { - case GESTURE_TAP: strcpy(gestureStrings[gesturesCount], "GESTURE TAP"); break; - case GESTURE_DOUBLETAP: strcpy(gestureStrings[gesturesCount], "GESTURE DOUBLETAP"); break; - case GESTURE_HOLD: strcpy(gestureStrings[gesturesCount], "GESTURE HOLD"); break; - case GESTURE_DRAG: strcpy(gestureStrings[gesturesCount], "GESTURE DRAG"); break; - case GESTURE_SWIPE_RIGHT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE RIGHT"); break; - case GESTURE_SWIPE_LEFT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE LEFT"); break; - case GESTURE_SWIPE_UP: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE UP"); break; - case GESTURE_SWIPE_DOWN: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE DOWN"); break; - case GESTURE_PINCH_IN: strcpy(gestureStrings[gesturesCount], "GESTURE PINCH IN"); break; - case GESTURE_PINCH_OUT: strcpy(gestureStrings[gesturesCount], "GESTURE PINCH OUT"); break; - default: break; - } - - gesturesCount++; - - // Reset gestures strings - if (gesturesCount >= MAX_GESTURE_STRINGS) - { - for (int i = 0; i < MAX_GESTURE_STRINGS; i++) strcpy(gestureStrings[i], "\0"); - - gesturesCount = 0; - } - } - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectangleRec(touchArea, GRAY); - DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, RAYWHITE); - - DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, Fade(GRAY, 0.5f)); - - for (int i = 0; i < gesturesCount; i++) - { - if (i%2 == 0) DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.5f)); - else DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.3f)); - - if (i < gesturesCount - 1) DrawText(gestureStrings[i], 35, 36 + 20*i, 10, DARKGRAY); - else DrawText(gestureStrings[i], 35, 36 + 20*i, 10, MAROON); - } - - DrawRectangleLines(10, 29, 200, screenHeight - 50, GRAY); - DrawText("DETECTED GESTURES", 50, 15, 10, GRAY); - - if (currentGesture != GESTURE_NONE) DrawCircleV(touchPosition, 30, MAROON); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- -}
\ No newline at end of file diff --git a/examples/src/core/core_input_keys.c b/examples/src/core/core_input_keys.c deleted file mode 100644 index bbb71ee..0000000 --- a/examples/src/core/core_input_keys.c +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Keyboard input -* -* 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 [core] example - keyboard input"); - - Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 }; - - 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 (IsKeyDown(KEY_RIGHT)) ballPosition.x += 2.0f; - if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 2.0f; - if (IsKeyDown(KEY_UP)) ballPosition.y -= 2.0f; - if (IsKeyDown(KEY_DOWN)) ballPosition.y += 2.0f; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY); - - DrawCircleV(ballPosition, 50, MAROON); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_input_mouse.c b/examples/src/core/core_input_mouse.c deleted file mode 100644 index ad205ae..0000000 --- a/examples/src/core/core_input_mouse.c +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Mouse input -* -* 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 [core] example - mouse input"); - - Vector2 ballPosition = { -100.0f, -100.0f }; - Color ballColor = DARKBLUE; - - 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 - //---------------------------------------------------------------------------------- - 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 - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawCircleV(ballPosition, 40, ballColor); - - DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_input_mouse_wheel.c b/examples/src/core/core_input_mouse_wheel.c deleted file mode 100644 index 7c3e2a1..0000000 --- a/examples/src/core/core_input_mouse_wheel.c +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] examples - Mouse wheel input -* -* This test has been created using raylib 1.1 (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 [core] example - input mouse wheel"); - - int boxPositionY = screenHeight/2 - 40; - int scrollSpeed = 4; // Scrolling speed in pixels - - 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 - //---------------------------------------------------------------------------------- - boxPositionY -= (GetMouseWheelMove()*scrollSpeed); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON); - - DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY); - DrawText(FormatText("Box position Y: %03i", boxPositionY), 10, 40, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_input_multitouch.c b/examples/src/core/core_input_multitouch.c deleted file mode 100644 index 5fbb086..0000000 --- a/examples/src/core/core_input_multitouch.c +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Input multitouch -* -* This example has been created using raylib 2.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Berni (@Berni8k) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2019 Berni (@Berni8k) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch"); - - Vector2 ballPosition = { -100.0f, -100.0f }; - Color ballColor = BEIGE; - - int touchCounter = 0; - Vector2 touchPosition = { 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 - //---------------------------------------------------------------------------------- - ballPosition = GetMousePosition(); - - ballColor = BEIGE; - - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) ballColor = MAROON; - if (IsMouseButtonDown(MOUSE_MIDDLE_BUTTON)) ballColor = LIME; - if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE; - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) touchCounter = 10; - if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) touchCounter = 10; - if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) touchCounter = 10; - - if (touchCounter > 0) touchCounter--; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Multitouch - for (int i = 0; i < MAX_TOUCH_POINTS; ++i) - { - touchPosition = GetTouchPosition(i); // Get the touch point - - if ((touchPosition.x >= 0) && (touchPosition.y >= 0)) // Make sure point is not (-1,-1) as this means there is no touch for it - { - // Draw circle and touch index number - DrawCircleV(touchPosition, 34, ORANGE); - DrawText(FormatText("%d", i), touchPosition.x - 10, touchPosition.y - 70, 40, BLACK); - } - } - - // Draw the normal mouse location - DrawCircleV(ballPosition, 30 + (touchCounter*3), ballColor); - - DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY); - DrawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_loading_thread.c b/examples/src/core/core_loading_thread.c deleted file mode 100644 index 773ad2e..0000000 --- a/examples/src/core/core_loading_thread.c +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************************* -* -* raylib example - loading thread -* -* NOTE: This example requires linking with pthreads library, -* on MinGW, it can be accomplished passing -static parameter to compiler -* -* 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 "pthread.h" // POSIX style threads management - -#include <stdatomic.h> // C11 atomic data types - -#include <time.h> // Required for: clock() - -// Using C11 atomics for synchronization -// NOTE: A plain bool (or any plain data type for that matter) can't be used for inter-thread synchronization -static atomic_bool dataLoaded = ATOMIC_VAR_INIT(false); // Data Loaded completion indicator -static void *LoadDataThread(void *arg); // Loading data thread function declaration - -static int dataProgress = 0; // Data progress accumulator - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread"); - - pthread_t threadId; // Loading data thread id - - enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING; - 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 STATE_WAITING: - { - if (IsKeyPressed(KEY_ENTER)) - { - int error = pthread_create(&threadId, NULL, &LoadDataThread, NULL); - if (error != 0) TraceLog(LOG_ERROR, "Error creating loading thread"); - else TraceLog(LOG_INFO, "Loading thread initialized successfully"); - - state = STATE_LOADING; - } - } break; - case STATE_LOADING: - { - framesCounter++; - if (atomic_load(&dataLoaded)) - { - framesCounter = 0; - state = STATE_FINISHED; - } - } break; - case STATE_FINISHED: - { - if (IsKeyPressed(KEY_ENTER)) - { - // Reset everything to launch again - atomic_store(&dataLoaded, false); - dataProgress = 0; - state = STATE_WAITING; - } - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch (state) - { - case STATE_WAITING: DrawText("PRESS ENTER to START LOADING DATA", 150, 170, 20, DARKGRAY); break; - case STATE_LOADING: - { - DrawRectangle(150, 200, dataProgress, 60, SKYBLUE); - if ((framesCounter/15)%2) DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE); - - } break; - case STATE_FINISHED: - { - DrawRectangle(150, 200, 500, 60, LIME); - DrawText("DATA LOADED!", 250, 210, 40, GREEN); - - } break; - default: break; - } - - DrawRectangleLines(150, 200, 500, 60, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -// Loading data thread function definition -static void *LoadDataThread(void *arg) -{ - int timeCounter = 0; // Time counted in ms - clock_t prevTime = clock(); // Previous time - - // We simulate data loading with a time counter for 5 seconds - while (timeCounter < 5000) - { - clock_t currentTime = clock() - prevTime; - timeCounter = currentTime*1000/CLOCKS_PER_SEC; - - // We accumulate time over a global variable to be used in - // main thread as a progress bar - dataProgress = timeCounter/10; - } - - // When data has finished loading, we set global variable - atomic_store(&dataLoaded, true); - - return NULL; -} diff --git a/examples/src/core/core_random_values.c b/examples/src/core/core_random_values.c deleted file mode 100644 index 52dabe0..0000000 --- a/examples/src/core/core_random_values.c +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Generate random values -* -* This example has been created using raylib 1.1 (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 [core] example - generate random values"); - - int framesCounter = 0; // Variable used to count frames - - int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included) - - 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 - //---------------------------------------------------------------------------------- - framesCounter++; - - // Every two seconds (120 frames) a new random value is generated - if (((framesCounter/120)%2) == 1) - { - randValue = GetRandomValue(-8, 5); - framesCounter = 0; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, MAROON); - - DrawText(FormatText("%i", randValue), 360, 180, 80, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_storage_values.c b/examples/src/core/core_storage_values.c deleted file mode 100644 index fbbbc52..0000000 --- a/examples/src/core/core_storage_values.c +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Storage save/load values -* -* This example has been created using raylib 1.4 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -// NOTE: Storage positions must start with 0, directly related to file memory layout -typedef enum { STORAGE_SCORE = 0, STORAGE_HISCORE } StorageData; - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - storage save/load values"); - - int score = 0; - int hiscore = 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_R)) - { - score = GetRandomValue(1000, 2000); - hiscore = GetRandomValue(2000, 4000); - } - - if (IsKeyPressed(KEY_ENTER)) - { - StorageSaveValue(STORAGE_SCORE, score); - StorageSaveValue(STORAGE_HISCORE, hiscore); - } - else if (IsKeyPressed(KEY_SPACE)) - { - // NOTE: If requested position could not be found, value 0 is returned - score = StorageLoadValue(STORAGE_SCORE); - hiscore = StorageLoadValue(STORAGE_HISCORE); - } - - framesCounter++; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText(FormatText("SCORE: %i", score), 280, 130, 40, MAROON); - DrawText(FormatText("HI-SCORE: %i", hiscore), 210, 200, 50, BLACK); - - DrawText(FormatText("frames: %i", framesCounter), 10, 10, 20, LIME); - - DrawText("Press R to generate random numbers", 220, 40, 20, LIGHTGRAY); - DrawText("Press ENTER to SAVE values", 250, 310, 20, LIGHTGRAY); - DrawText("Press SPACE to LOAD values", 252, 350, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_vr_simulator.c b/examples/src/core/core_vr_simulator.c deleted file mode 100644 index 134a36f..0000000 --- a/examples/src/core/core_vr_simulator.c +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - VR Simulator (Oculus Rift CV1 parameters) -* -* 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" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1080; - const int screenHeight = 600; - - // NOTE: screenWidth/screenHeight should match VR device aspect ratio - - InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator"); - - // Init VR simulator (Oculus Rift CV1 parameters) - InitVrSimulator(); - - VrDeviceInfo hmd = { 0 }; // VR device parameters (head-mounted-device) - - // Oculus Rift CV1 parameters for simulator - hmd.hResolution = 2160; // HMD horizontal resolution in pixels - hmd.vResolution = 1200; // HMD vertical resolution in pixels - hmd.hScreenSize = 0.133793f; // HMD horizontal size in meters - hmd.vScreenSize = 0.0669f; // HMD vertical size in meters - hmd.vScreenCenter = 0.04678f; // HMD screen center in meters - hmd.eyeToScreenDistance = 0.041f; // HMD distance between eye and display in meters - hmd.lensSeparationDistance = 0.07f; // HMD lens separation distance in meters - hmd.interpupillaryDistance = 0.07f; // HMD IPD (distance between pupils) in meters - - // NOTE: CV1 uses a Fresnel-hybrid-asymmetric lenses with specific distortion compute shaders. - // Following parameters are an approximation to distortion stereo rendering but results differ from actual device. - hmd.lensDistortionValues[0] = 1.0f; // HMD lens distortion constant parameter 0 - hmd.lensDistortionValues[1] = 0.22f; // HMD lens distortion constant parameter 1 - hmd.lensDistortionValues[2] = 0.24f; // HMD lens distortion constant parameter 2 - hmd.lensDistortionValues[3] = 0.0f; // HMD lens distortion constant parameter 3 - hmd.chromaAbCorrection[0] = 0.996f; // HMD chromatic aberration correction parameter 0 - hmd.chromaAbCorrection[1] = -0.004f; // HMD chromatic aberration correction parameter 1 - hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2 - hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3 - - // Distortion shader (uses device lens distortion and chroma) - Shader distortion = LoadShader(0, FormatText("resources/distortion%i.fs", GLSL_VERSION)); - - SetVrConfiguration(hmd, distortion); // Set Vr device parameters for stereo rendering - - // Define the camera to look into our 3d world - Camera camera; - camera.position = (Vector3){ 5.0f, 2.0f, 5.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 60.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera type - - Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; - - SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set first person camera mode - - SetTargetFPS(90); // Set our game to run at 90 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update camera (simulator mode) - - if (IsKeyPressed(KEY_SPACE)) ToggleVrMode(); // Toggle VR mode - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginVrDrawing(); - - BeginMode3D(camera); - - DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); - DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); - - DrawGrid(40, 1.0f); - - EndMode3D(); - - EndVrDrawing(); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadShader(distortion); // Unload distortion shader - - CloseVrSimulator(); // Close VR simulator - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_window_letterbox.c b/examples/src/core/core_window_letterbox.c deleted file mode 100644 index f90214c..0000000 --- a/examples/src/core/core_window_letterbox.c +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - window scale letterbox -* -* 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 Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2019 Anata (@anatagawa) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define max(a, b) ((a)>(b)? (a) : (b)) -#define min(a, b) ((a)<(b)? (a) : (b)) - -int main(void) -{ - const int windowWidth = 800; - const int windowHeight = 450; - - // Enable config flags for resizable window and vertical synchro - SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT); - InitWindow(windowWidth, windowHeight, "raylib [core] example - window scale letterbox"); - SetWindowMinSize(320, 240); - - int gameScreenWidth = 640; - int gameScreenHeight = 480; - - // Render texture initialization - RenderTexture2D target = LoadRenderTexture(gameScreenWidth, gameScreenHeight); - SetTextureFilter(target.texture, FILTER_BILINEAR); // Texture scale filter to use - - Color colors[10] = { 0 }; - for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 }; - - 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 - //---------------------------------------------------------------------------------- - // Compute required framebuffer scaling - float scale = min((float)GetScreenWidth()/gameScreenWidth, (float)GetScreenHeight()/gameScreenHeight); - - if (IsKeyPressed(KEY_SPACE)) - { - // Recalculate random colors for the bars - for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 }; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - ClearBackground(BLACK); - - // Draw everything in the render texture - BeginTextureMode(target); - - ClearBackground(RAYWHITE); // Clear render texture background color - - for (int i = 0; i < 10; i++) DrawRectangle(0, (gameScreenHeight/10)*i, gameScreenWidth, gameScreenHeight/10, colors[i]); - - DrawText("You can resize the window,\nand see the screen scaling!", 10, 25, 20, WHITE); - - EndTextureMode(); - - // Draw RenderTexture2D to window, properly scaled - DrawTexturePro(target.texture, (Rectangle){ 0.0f, 0.0f, (float)target.texture.width, (float)-target.texture.height }, - (Rectangle){ (GetScreenWidth() - ((float)gameScreenWidth*scale))*0.5, (GetScreenHeight() - ((float)gameScreenHeight*scale))*0.5, - (float)gameScreenWidth*scale, (float)gameScreenHeight*scale }, (Vector2){ 0, 0 }, 0.0f, WHITE); - - EndDrawing(); - //-------------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadRenderTexture(target); // Unload render texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/core/core_world_screen.c b/examples/src/core/core_world_screen.c deleted file mode 100644 index 434952b..0000000 --- a/examples/src/core/core_world_screen.c +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - World to screen -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); - - // Define the camera to look into our 3d world - Camera camera = { 0 }; - camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - camera.fovy = 45.0f; - camera.type = CAMERA_PERSPECTIVE; - - Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; - - Vector2 cubeScreenPosition; - - SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode - - 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 - //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update camera - - // Calculate cube screen space position (with a little offset to be in top) - cubeScreenPosition = GetWorldToScreen((Vector3){cubePosition.x, cubePosition.y + 2.5f, cubePosition.z}, camera); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); - DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); - - DrawGrid(10, 1.0f); - - EndMode3D(); - - DrawText("Enemy: 100 / 100", cubeScreenPosition.x - MeasureText("Enemy: 100 / 100", 20) / 2, cubeScreenPosition.y, 20, BLACK); - DrawText("Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20)) / 2, 25, 20, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file |
