diff options
| author | Ray <[email protected]> | 2019-05-20 16:40:30 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2019-05-20 16:40:30 +0200 |
| commit | 3d7d174c70b2d00fd879ade64c5085d4ff34d4aa (patch) | |
| tree | 3b690948f186f855aa2ee8bab312b3ca28a56200 /examples/src/core | |
| parent | 0b56b996bd053ec875c229e9793f7806b666839c (diff) | |
| download | raylib.com-3d7d174c70b2d00fd879ade64c5085d4ff34d4aa.tar.gz raylib.com-3d7d174c70b2d00fd879ade64c5085d4ff34d4aa.zip | |
Review and recompile ALL examples
Diffstat (limited to 'examples/src/core')
20 files changed, 268 insertions, 269 deletions
diff --git a/examples/src/core/core_2d_camera.c b/examples/src/core/core_2d_camera.c index 6a0b11a..fe8e584 100644 --- a/examples/src/core/core_2d_camera.c +++ b/examples/src/core/core_2d_camera.c @@ -13,21 +13,21 @@ #define MAX_BUILDINGS 100 -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + 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); @@ -36,22 +36,22 @@ int main() buildings[i].x = -6000 + spacing; spacing += buildings[i].width; - + buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 }; } - - Camera2D camera; - + + 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); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- @@ -65,26 +65,26 @@ int main() 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; + 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)) + if (IsKeyPressed(KEY_R)) { camera.zoom = 1.0f; camera.rotation = 0.0f; @@ -94,32 +94,32 @@ int main() // 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); @@ -131,7 +131,7 @@ int main() } // De-Initialization - //-------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/src/core/core_3d_camera_first_person.c b/examples/src/core/core_3d_camera_first_person.c index d3a8f2e..825a9ca 100644 --- a/examples/src/core/core_3d_camera_first_person.c +++ b/examples/src/core/core_3d_camera_first_person.c @@ -13,15 +13,15 @@ #define MAX_COLUMNS 20 -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + 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 }; @@ -34,14 +34,14 @@ int main() 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 @@ -67,7 +67,7 @@ int main() 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++) { @@ -76,7 +76,7 @@ int main() } EndMode3D(); - + DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f)); DrawRectangleLines( 10, 10, 220, 70, BLUE); @@ -89,7 +89,7 @@ int main() } // De-Initialization - //-------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/src/core/core_3d_camera_free.c b/examples/src/core/core_3d_camera_free.c index 9131ddf..c1445f6 100644 --- a/examples/src/core/core_3d_camera_free.c +++ b/examples/src/core/core_3d_camera_free.c @@ -11,12 +11,12 @@ #include "raylib.h" -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + const int screenWidth = 800; + const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); @@ -27,9 +27,9 @@ int main() 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 @@ -41,7 +41,7 @@ int main() // Update //---------------------------------------------------------------------------------- UpdateCamera(&camera); // Update camera - + if (IsKeyDown('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; //---------------------------------------------------------------------------------- @@ -59,10 +59,10 @@ int main() 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); diff --git a/examples/src/core/core_3d_camera_mode.c b/examples/src/core/core_3d_camera_mode.c index a496220..eae6c88 100644 --- a/examples/src/core/core_3d_camera_mode.c +++ b/examples/src/core/core_3d_camera_mode.c @@ -11,7 +11,7 @@ #include "raylib.h" -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- @@ -30,7 +30,7 @@ int main() Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop diff --git a/examples/src/core/core_3d_picking.c b/examples/src/core/core_3d_picking.c index 1c63e2a..1e60c03 100644 --- a/examples/src/core/core_3d_picking.c +++ b/examples/src/core/core_3d_picking.c @@ -11,12 +11,12 @@ #include "raylib.h" -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + const int screenWidth = 800; + const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking"); diff --git a/examples/src/core/core_basic_window.c b/examples/src/core/core_basic_window.c index b30f05d..3c103a5 100644 --- a/examples/src/core/core_basic_window.c +++ b/examples/src/core/core_basic_window.c @@ -21,16 +21,16 @@ #include "raylib.h" -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + const int screenWidth = 800; + const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); - - SetTargetFPS(60); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -54,7 +54,7 @@ int main() } // De-Initialization - //-------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/src/core/core_custom_logging.c b/examples/src/core/core_custom_logging.c index cf1a601..0ab3fa4 100644 --- a/examples/src/core/core_custom_logging.c +++ b/examples/src/core/core_custom_logging.c @@ -19,66 +19,66 @@ // 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"); + 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 - //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + // 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); + // 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"); + InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging"); - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- + 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 - //---------------------------------------------------------------------------------- + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); - ClearBackground(RAYWHITE); + ClearBackground(RAYWHITE); - DrawText("Check out the console output to see the custom logger in action!", 60, 200, 20, LIGHTGRAY); + DrawText("Check out the console output to see the custom logger in action!", 60, 200, 20, LIGHTGRAY); - EndDrawing(); - //---------------------------------------------------------------------------------- - } + EndDrawing(); + //---------------------------------------------------------------------------------- + } - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- - return 0; + return 0; } diff --git a/examples/src/core/core_drop_files.c b/examples/src/core/core_drop_files.c index 5c1501b..5c3af6a 100644 --- a/examples/src/core/core_drop_files.c +++ b/examples/src/core/core_drop_files.c @@ -13,19 +13,19 @@ #include "raylib.h" -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + const int screenWidth = 800; + const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files"); - + int count = 0; char **droppedFiles = { 0 }; - - SetTargetFPS(60); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -49,15 +49,15 @@ int main() 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); } @@ -68,7 +68,7 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- ClearDroppedFiles(); // Clear internal buffers - + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/src/core/core_input_gamepad.c b/examples/src/core/core_input_gamepad.c index e8a1c05..51646aa 100644 --- a/examples/src/core/core_input_gamepad.c +++ b/examples/src/core/core_input_gamepad.c @@ -3,15 +3,15 @@ * raylib [core] example - Gamepad input * * NOTE: This example requires a Gamepad connected to the system -* raylib is configured to work with the following gamepads: +* raylib is configured to work with the following gamepads: * - Xbox 360 Controller (Xbox 360, Xbox One) -* - PLAYSTATION(R)3 Controller +* - PLAYSTATION(R)3 Controller * Check raylib.h for buttons configuration * -* This example has been created using raylib 1.6 (www.raylib.com) +* 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-2016 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) * ********************************************************************************************/ @@ -26,21 +26,21 @@ #define PS3_NAME_ID "PLAYSTATION(R)3 Controller" #endif -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + const int screenWidth = 800; + const int screenHeight = 450; + + SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation - 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); + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -56,7 +56,7 @@ int main() BeginDrawing(); ClearBackground(RAYWHITE); - + if (IsGamepadAvailable(GAMEPAD_PLAYER1)) { DrawText(FormatText("GP1: %s", GetGamepadName(GAMEPAD_PLAYER1)), 10, 10, 10, BLACK); @@ -64,7 +64,7 @@ int main() 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); @@ -75,7 +75,7 @@ int main() 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); @@ -83,7 +83,7 @@ int main() 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); @@ -91,21 +91,21 @@ int main() // Draw axis: left joystick DrawCircle(259, 152, 39, BLACK); DrawCircle(259, 152, 34, LIGHTGRAY); - DrawCircle(259 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_X)*20), + 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), + 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(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); } @@ -115,7 +115,7 @@ int main() // 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); @@ -131,7 +131,7 @@ int main() 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); @@ -139,42 +139,42 @@ int main() // Draw axis: left joystick DrawCircle(319, 255, 35, BLACK); DrawCircle(319, 255, 31, LIGHTGRAY); - DrawCircle(319 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_X)*20), + 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), + 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(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); - + + 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); } @@ -186,7 +186,7 @@ int main() //-------------------------------------------------------------------------------------- UnloadTexture(texPs3Pad); UnloadTexture(texXboxPad); - + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/src/core/core_input_gestures.c b/examples/src/core/core_input_gestures.c index ce2ed86..affab3e 100644 --- a/examples/src/core/core_input_gestures.c +++ b/examples/src/core/core_input_gestures.c @@ -14,27 +14,27 @@ #define MAX_GESTURE_STRINGS 20 -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - + 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); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -65,14 +65,14 @@ int main() 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; } } @@ -84,32 +84,32 @@ int main() 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 index 69384fd..bbb71ee 100644 --- a/examples/src/core/core_input_keys.c +++ b/examples/src/core/core_input_keys.c @@ -11,18 +11,18 @@ #include "raylib.h" -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + 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 target frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop diff --git a/examples/src/core/core_input_mouse.c b/examples/src/core/core_input_mouse.c index 24d2dfc..ad205ae 100644 --- a/examples/src/core/core_input_mouse.c +++ b/examples/src/core/core_input_mouse.c @@ -11,19 +11,19 @@ #include "raylib.h" -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + 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); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //--------------------------------------------------------------------------------------- // Main game loop @@ -32,7 +32,7 @@ int main() // 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; diff --git a/examples/src/core/core_input_mouse_wheel.c b/examples/src/core/core_input_mouse_wheel.c index 48cf704..7c3e2a1 100644 --- a/examples/src/core/core_input_mouse_wheel.c +++ b/examples/src/core/core_input_mouse_wheel.c @@ -11,19 +11,19 @@ #include "raylib.h" -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + 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); + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop diff --git a/examples/src/core/core_input_multitouch.c b/examples/src/core/core_input_multitouch.c index 5baab27..5fbb086 100644 --- a/examples/src/core/core_input_multitouch.c +++ b/examples/src/core/core_input_multitouch.c @@ -13,31 +13,31 @@ #include "raylib.h" -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + 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; + Vector2 touchPosition = { 0.0f }; - SetTargetFPS(60); + 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; @@ -47,7 +47,7 @@ int main() 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--; //---------------------------------------------------------------------------------- @@ -59,15 +59,15 @@ int main() // 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 diff --git a/examples/src/core/core_loading_thread.c b/examples/src/core/core_loading_thread.c index 1dacd69..773ad2e 100644 --- a/examples/src/core/core_loading_thread.c +++ b/examples/src/core/core_loading_thread.c @@ -2,7 +2,7 @@ * * raylib example - loading thread * -* NOTE: This example requires linking with pthreads library, +* 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) @@ -27,21 +27,21 @@ static void *LoadDataThread(void *arg); // Loading data thread function decl static int dataProgress = 0; // Data progress accumulator -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + 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); + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -90,25 +90,25 @@ int main() BeginDrawing(); ClearBackground(RAYWHITE); - - switch (state) + + 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(); @@ -130,11 +130,11 @@ static void *LoadDataThread(void *arg) clock_t prevTime = clock(); // Previous time // We simulate data loading with a time counter for 5 seconds - while (timeCounter < 5000) + 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; diff --git a/examples/src/core/core_random_values.c b/examples/src/core/core_random_values.c index 06e550d..52dabe0 100644 --- a/examples/src/core/core_random_values.c +++ b/examples/src/core/core_random_values.c @@ -11,20 +11,20 @@ #include "raylib.h" -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + 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 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 + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop diff --git a/examples/src/core/core_storage_values.c b/examples/src/core/core_storage_values.c index 43f0882..fbbbc52 100644 --- a/examples/src/core/core_storage_values.c +++ b/examples/src/core/core_storage_values.c @@ -14,21 +14,20 @@ // NOTE: Storage positions must start with 0, directly related to file memory layout typedef enum { STORAGE_SCORE = 0, STORAGE_HISCORE } StorageData; -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + 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); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -41,7 +40,7 @@ int main() score = GetRandomValue(1000, 2000); hiscore = GetRandomValue(2000, 4000); } - + if (IsKeyPressed(KEY_ENTER)) { StorageSaveValue(STORAGE_SCORE, score); @@ -53,7 +52,7 @@ int main() score = StorageLoadValue(STORAGE_SCORE); hiscore = StorageLoadValue(STORAGE_HISCORE); } - + framesCounter++; //---------------------------------------------------------------------------------- @@ -65,9 +64,9 @@ int main() 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); @@ -77,7 +76,7 @@ int main() } // De-Initialization - //-------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/src/core/core_vr_simulator.c b/examples/src/core/core_vr_simulator.c index b79ed90..134a36f 100644 --- a/examples/src/core/core_vr_simulator.c +++ b/examples/src/core/core_vr_simulator.c @@ -17,22 +17,22 @@ #define GLSL_VERSION 100 #endif -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 1080; - int screenHeight = 600; - + 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 @@ -42,7 +42,7 @@ int main() 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 @@ -53,12 +53,12 @@ int main() 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 @@ -66,11 +66,11 @@ int main() 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 //-------------------------------------------------------------------------------------- @@ -89,7 +89,7 @@ int main() BeginDrawing(); ClearBackground(RAYWHITE); - + BeginVrDrawing(); BeginMode3D(camera); @@ -100,7 +100,7 @@ int main() DrawGrid(40, 1.0f); EndMode3D(); - + EndVrDrawing(); DrawFPS(10, 10); diff --git a/examples/src/core/core_window_letterbox.c b/examples/src/core/core_window_letterbox.c index 8c0843d..f90214c 100644 --- a/examples/src/core/core_window_letterbox.c +++ b/examples/src/core/core_window_letterbox.c @@ -16,7 +16,7 @@ #define max(a, b) ((a)>(b)? (a) : (b)) #define min(a, b) ((a)<(b)? (a) : (b)) -int main() +int main(void) { const int windowWidth = 800; const int windowHeight = 450; @@ -28,63 +28,63 @@ int main() 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); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- - + // Main game loop - while( !WindowShouldClose() ) // Detect window close button or ESC key + 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)) + + 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, + (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 index 460f6b8..434952b 100644 --- a/examples/src/core/core_world_screen.c +++ b/examples/src/core/core_world_screen.c @@ -11,12 +11,12 @@ #include "raylib.h" -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; + const int screenWidth = 800; + const int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); @@ -29,9 +29,9 @@ int main() 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 @@ -43,7 +43,7 @@ int main() // 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); //---------------------------------------------------------------------------------- @@ -62,7 +62,7 @@ int main() 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); |
