examples/core_input_gamepad: arrows left/right to choose gamepad

This commit is contained in:
Locria Cyber 2023-06-13 20:18:16 +00:00
parent 4204e11b14
commit e90739ca57
No known key found for this signature in database
GPG Key ID: ED0D424AE4406330

View File

@ -49,6 +49,8 @@ int main(void)
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
int gamepad = 0; // which gamepad to display
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
@ -62,7 +64,9 @@ int main(void)
BeginDrawing();
ClearBackground(RAYWHITE);
int gamepad = 1;
if (IsKeyPressed(KEY_LEFT) && gamepad > 0) gamepad--;
if (IsKeyPressed(KEY_RIGHT)) gamepad++;
if (IsGamepadAvailable(gamepad))
{
@ -189,7 +193,7 @@ int main(void)
}
else
{
DrawText("GP1: NOT DETECTED", 10, 10, 10, GRAY);
DrawText(TextFormat("GP%d: NOT DETECTED", gamepad), 10, 10, 10, GRAY);
DrawTexture(texXboxPad, 0, 0, LIGHTGRAY);
}