Skip to content

Commit

Permalink
Stats are now closed on a key release, instead of a key press
Browse files Browse the repository at this point in the history
  • Loading branch information
bit69tream committed Jan 13, 2024
1 parent 43901d4 commit 80a8e87
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/stribun.c
Original file line number Diff line number Diff line change
Expand Up @@ -5355,10 +5355,27 @@ char *perkName(Perk perk) {
assert(false);
}

static bool pressedKeys[420] = {0};

void updateAndRenderStats(void) {
if (GetKeyPressed() != KEY_NULL ||
IsMouseButtonPressed(MOUSE_BUTTON_LEFT) ||
IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) {
KeyboardKey key = KEY_NULL;

if ((key = GetKeyPressed()) != KEY_NULL) {
pressedKeys[key] = true;
}

bool anyKeyReleased = false;
for (int i = 0; i < sizeof(pressedKeys) / sizeof(pressedKeys[0]); i++) {
if (pressedKeys[i] && IsKeyReleased(i)) {
anyKeyReleased = true;
memset(pressedKeys, 0, sizeof(pressedKeys));
break;
}
}

if (anyKeyReleased ||
IsMouseButtonReleased(MOUSE_BUTTON_LEFT) ||
IsMouseButtonReleased(MOUSE_BUTTON_RIGHT)) {
PlaySound(beep);

if (player.health == 0) {
Expand Down

0 comments on commit 80a8e87

Please sign in to comment.