-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.cpp.txt
More file actions
36 lines (26 loc) · 1007 Bytes
/
Copy pathInput.cpp.txt
File metadata and controls
36 lines (26 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "input.h"
void Input::beginNewFrame() { //funzione chiamata nei casi di nuovo frame per
this->_pressKeys.clear(); //per resettare i pulsanti che non servono
this->_releasedKeys.clear();
}
//Pulsante premuto
void Input::keyDownEvent(const SDL_Event& event) {
this->_pressKeys[event.key.keysym.scancode] = true;
this->_heldKeys[event.key.keysym.scancode] = true;
}
//Pulsante rilasciato
void Input::keyUpEvent(const SDL_Event& event) {
this->_releasedKeys[event.key.keysym.scancode] = true;
this->_heldKeys[event.key.kesym.scancode] = false; //Falso perchè non stiamo più tenendo premuto il pulsante
}
//Controlla se un certo pulsante è stato premuto
bool Input::wasKeyPressed(SDL_Scancode key) {
return this->_pressedKeys[key];
}
// Controlla se un certo pulsante è stato rilasciato
bool Input::wasKeyReleased(SDL_Scancode key) {
return this->_releasedKeys[key];
}
bool Input::isKeyHeld(SDL_Scancode key) {
return this->_heldKeys[key];
}