mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2026-02-04 09:19:19 +01:00
Lmao, git removed some things :>(
This commit is contained in:
@@ -765,6 +765,26 @@ bool utils::isKeyDown(int keycode) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static bool s_KeyStates[256] = {false};
|
||||
bool utils::isKeyPressed(int keycode) {
|
||||
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
||||
if (pStates != nullptr) {
|
||||
if(pStates[keycode] && !s_KeyStates[keycode]) {
|
||||
s_KeyStates[keycode] = true;
|
||||
return s_KeyStates[keycode];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool utils::isKeyUp(int keycode) {
|
||||
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
||||
if(pStates[keycode] == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool utils::isMouseDown(int button) {
|
||||
const Uint32 pStates = SDL_GetMouseState(nullptr, nullptr);
|
||||
if (pStates & SDL_BUTTON(button)) {
|
||||
|
||||
@@ -107,6 +107,8 @@ namespace utils
|
||||
#pragma endregion CollisionFunctionality
|
||||
|
||||
bool isKeyDown(SDL_Keycode keycode);
|
||||
bool isKeyPressed(int keycode);
|
||||
bool isMouseDown(int button);
|
||||
bool isKeyUp(int keycode);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user