-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.cpp
More file actions
46 lines (39 loc) · 1.04 KB
/
player.cpp
File metadata and controls
46 lines (39 loc) · 1.04 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
39
40
41
42
43
44
45
46
#include "player.h"
unsigned int Player::_count = 0;
Player::Player() : Entity(1,1), speed(0.0), still(true), dir(d), alive(true) {
_count++;
}
Player::~Player() {
--_count;
}
void Player::calcDirection(const bool(* const keys)[1024]) {
//get direction player is currently going in
Dir direction = (Dir)dir;
Player::still = false;
if ((*keys)[GLFW_KEY_W]) {
direction = Dir::w;
if ((*keys)[GLFW_KEY_A]) {
direction = Dir::wa;
}
else if ((*keys)[GLFW_KEY_D]) {
direction = Dir::wd;
}
}
else if ((*keys)[GLFW_KEY_S]) {
direction = Dir::s;
if ((*keys)[GLFW_KEY_A]) {
direction = Dir::sa;
}
else if ((*keys)[GLFW_KEY_D]) {
direction = Dir::sd;
}
}
else if ((*keys)[GLFW_KEY_A]) {
direction = Dir::a;
}
else if ((*keys)[GLFW_KEY_D]) {
direction = Dir::d;
}
else Player::still = true;
dir = (unsigned int)direction;
}