Fixed writing out of array bounds
Adjusted FPS comment to match value
Deleted unused function at the end, which has never been in use in the history of this file
This commit is contained in:
Alexander Buhl 2020-12-12 17:57:08 +01:00 committed by GitHub
parent e6ae4879f6
commit 2fa083b9de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,7 +30,7 @@ int main(void)
int framesCounter = 0; int framesCounter = 0;
SetTargetFPS(10); // Set our game to run at 60 frames-per-second SetTargetFPS(10); // Set our game to run at 10 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
@ -65,9 +65,8 @@ int main(void)
if (IsKeyPressed(KEY_BACKSPACE)) if (IsKeyPressed(KEY_BACKSPACE))
{ {
letterCount--; letterCount--;
name[letterCount] = '\0';
if (letterCount < 0) letterCount = 0; if (letterCount < 0) letterCount = 0;
name[letterCount] = '\0';
} }
} }
else if (GetMouseCursor() != MOUSE_CURSOR_DEFAULT) SetMouseCursor(MOUSE_CURSOR_DEFAULT); else if (GetMouseCursor() != MOUSE_CURSOR_DEFAULT) SetMouseCursor(MOUSE_CURSOR_DEFAULT);
@ -113,15 +112,3 @@ int main(void)
return 0; return 0;
} }
// Check if any key is pressed
// NOTE: We limit keys check to keys between 32 (KEY_SPACE) and 126
bool IsAnyKeyPressed()
{
bool keyPressed = false;
int key = GetKeyPressed();
if ((key >= 32) && (key <= 126)) keyPressed = true;
return keyPressed;
}