-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayer.cpp
49 lines (40 loc) · 904 Bytes
/
player.cpp
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
47
48
49
#include "player.h"
Player::Player() {
this->angle = Radian(0);
this->FOV = Radian(60);
this->health = 5;
this->score = 0;
}
Radian Player::getAngle() {
return this->angle;
}
Radian Player::getFov() {
return this->FOV;
}
void Player::turnLeft(Radian amount) {
this->angle.add(amount);
printf("New angle: %f\n", this->angle.toRad());
}
void Player::turnRight(Radian amount) {
this->angle.subtract(amount);
printf("New angle: %f\n", this->angle.toRad());
}
Vector2 Player::getVector() {
Vector2 pvector(cos(this->angle.toRad()), sin(this->angle.toRad()));
return pvector;
}
void Player::loseHealth() {
health--;
}
int Player::getHealth() {
return health;
}
int Player::getScore() {
return this->score;
}
void Player::setScore(int newScore) {
this->score = newScore;
}
void Player::addScore(int addend) {
this->score += addend;
}