examples/core_input_gamepad: arrows left/right to choose gamepad
This commit is contained in:
parent
4204e11b14
commit
e90739ca57
|
|
@ -49,6 +49,8 @@ int main(void)
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int gamepad = 0; // which gamepad to display
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
|
|
@ -62,7 +64,9 @@ int main(void)
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
int gamepad = 1;
|
|
||||||
|
if (IsKeyPressed(KEY_LEFT) && gamepad > 0) gamepad--;
|
||||||
|
if (IsKeyPressed(KEY_RIGHT)) gamepad++;
|
||||||
|
|
||||||
if (IsGamepadAvailable(gamepad))
|
if (IsGamepadAvailable(gamepad))
|
||||||
{
|
{
|
||||||
|
|
@ -189,7 +193,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
else
|
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);
|
DrawTexture(texXboxPad, 0, 0, LIGHTGRAY);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user