From bbf0c3a46d27b723e73483bdd787c7713b31fe1a Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 8 Nov 2023 17:41:08 +0100 Subject: REVIEWED: Added new examples to VS2022 solution --- examples/core/core_3d_camera_free.c | 2 +- examples/core/core_automation_events.png | Bin 0 -> 17155 bytes examples/core/core_input_gamepad_info.c | 45 ++++++++++++++++++------------- 3 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 examples/core/core_automation_events.png (limited to 'examples/core') diff --git a/examples/core/core_3d_camera_free.c b/examples/core/core_3d_camera_free.c index ec849758..3c30a426 100644 --- a/examples/core/core_3d_camera_free.c +++ b/examples/core/core_3d_camera_free.c @@ -47,7 +47,7 @@ int main(void) //---------------------------------------------------------------------------------- UpdateCamera(&camera, CAMERA_FREE); - if (IsKeyDown('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; + if (IsKeyPressed('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; //---------------------------------------------------------------------------------- // Draw diff --git a/examples/core/core_automation_events.png b/examples/core/core_automation_events.png new file mode 100644 index 00000000..49cf3282 Binary files /dev/null and b/examples/core/core_automation_events.png differ diff --git a/examples/core/core_input_gamepad_info.c b/examples/core/core_input_gamepad_info.c index 55f0354b..9aebb815 100644 --- a/examples/core/core_input_gamepad_info.c +++ b/examples/core/core_input_gamepad_info.c @@ -31,40 +31,49 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad information"); 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 { - int y = 10; + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + // Draw + //---------------------------------------------------------------------------------- BeginDrawing(); - ClearBackground(RAYWHITE); + ClearBackground(RAYWHITE); - for (int i = 0; i < 4; i++) // by default rcore.h has a MAX_GAMEPADS of 4 so mimmic that here. - { - if (IsGamepadAvailable(i)) + for (int i = 0, y = 10; i < 4; i++) // MAX_GAMEPADS = 4 { - DrawText(TextFormat("Gamepad name: %s", GetGamepadName(i)), 10, y, 20, BLACK); - y += 30; - DrawText(TextFormat("\tAxis count: %d", GetGamepadAxisCount(i)), 10, y, 20, BLACK); - y += 30; - for (int axis = 0; axis < GetGamepadAxisCount(i); axis++) + if (IsGamepadAvailable(i)) { - DrawText(TextFormat("\tAxis %d = %f", axis, GetGamepadAxisMovement(i, axis)), 10, y, 20, BLACK); + DrawText(TextFormat("Gamepad name: %s", GetGamepadName(i)), 10, y, 20, BLACK); y += 30; - } - for (int button = 0; button < 32; button++) - { - DrawText(TextFormat("\tButton %d = %d", button, IsGamepadButtonDown(i, button)), 10, y, 20, BLACK); + DrawText(TextFormat("\tAxis count: %d", GetGamepadAxisCount(i)), 10, y, 20, BLACK); y += 30; + + for (int axis = 0; axis < GetGamepadAxisCount(i); axis++) + { + DrawText(TextFormat("\tAxis %d = %f", axis, GetGamepadAxisMovement(i, axis)), 10, y, 20, BLACK); + y += 30; + } + + for (int button = 0; button < 32; button++) + { + DrawText(TextFormat("\tButton %d = %d", button, IsGamepadButtonDown(i, button)), 10, y, 20, BLACK); + y += 30; + } } } - } - DrawFPS(GetScreenWidth() - 100, 100); + DrawFPS(GetScreenWidth() - 100, 100); EndDrawing(); + //---------------------------------------------------------------------------------- } // De-Initialization -- cgit v1.2.3