Skip to content

Commit 48496e2

Browse files
committed
Update core_input_actions.c
1 parent e6ef992 commit 48496e2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

examples/core/core_input_actions.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ int main(void)
7171
// Set default actions
7272
char actionSet = 0;
7373
SetActionsDefault();
74+
bool releaseAction = false;
7475

7576
Vector2 position = (Vector2){ 400.0f, 200.0f };
7677
Vector2 size = (Vector2){ 40.0f, 40.0f };
@@ -83,7 +84,8 @@ int main(void)
8384
{
8485
// Update
8586
//----------------------------------------------------------------------------------
86-
gamepadIndex = 0; // set this to gamepad being checked
87+
gamepadIndex = 0; // Set gamepad being checked
88+
8789
if (IsActionDown(ACTION_UP)) position.y -= 2;
8890
if (IsActionDown(ACTION_DOWN)) position.y += 2;
8991
if (IsActionDown(ACTION_LEFT)) position.x -= 2;
@@ -93,6 +95,10 @@ int main(void)
9395
position.x = (screenWidth-size.x)/2;
9496
position.y = (screenHeight-size.y)/2;
9597
}
98+
99+
// Register release action for one frame
100+
releaseAction = false;
101+
if (IsActionReleased(ACTION_FIRE)) releaseAction = true;
96102

97103
// Switch control scheme by pressing TAB
98104
if (IsKeyPressed(KEY_TAB))
@@ -109,7 +115,7 @@ int main(void)
109115

110116
ClearBackground(GRAY);
111117

112-
DrawRectangleV(position, size, RED);
118+
DrawRectangleV(position, size, releaseAction? BLUE : RED);
113119

114120
DrawText((actionSet == 0)? "Current input set: WASD (default)" : "Current input set: Cursor", 10, 10, 20, WHITE);
115121
DrawText("Use TAB key to toggles Actions keyset", 10, 50, 20, GREEN);

0 commit comments

Comments
 (0)