-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotationIC.cpp
More file actions
39 lines (33 loc) · 1.1 KB
/
RotationIC.cpp
File metadata and controls
39 lines (33 loc) · 1.1 KB
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
37
38
#include "RotationIC.h"
#include "Fighter.h"
RotationIC::RotationIC(SDL_Keycode ctrlKey0, SDL_Keycode ctrlKey1, float angle) :
ctrlKey0_(ctrlKey0), ctrlKey1_(ctrlKey1), ang_(angle)
{
}
RotationIC::~RotationIC() {}
void RotationIC::handleInput(Container* c, Uint32 time) {
if (InputHandler::getInstance()->isAnyKeyDown()) {
if (InputHandler::getInstance()->isKeyDown(ctrlKey0_)) {
//Activar rotacion der
static_cast<Fighter*>(c)->setRotating(true);
static_cast<Fighter*>(c)->setRot(ang_);
}
else if (InputHandler::getInstance()->isKeyDown(ctrlKey1_)) {
//Activar rot izq
static_cast<Fighter*>(c)->setRotating(true);
static_cast<Fighter*>(c)->setRot(-ang_);
}
}
if (InputHandler::getInstance()->isAnyKeyUp()) {
if (InputHandler::getInstance()->isKeyDown(ctrlKey0_) == false) {
//Desactivar rot der
static_cast<Fighter*>(c)->setRotating(false);
static_cast<Fighter*>(c)->setRot(0);
}
else if (InputHandler::getInstance()->isKeyDown(ctrlKey1_) == false) {
//Desactivar rot izq
static_cast<Fighter*>(c)->setRotating(false);
static_cast<Fighter*>(c)->setRot(0);
}
}
}