-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cpp
More file actions
84 lines (72 loc) · 1.21 KB
/
Copy pathPlayer.cpp
File metadata and controls
84 lines (72 loc) · 1.21 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "src/Player.h"
Player::Player() : _health(200)
{
_camera = new Camera();
}
Player::Player(Vector3f pos) : _health(200)
{
_position = pos;
_camera = new Camera(pos);
}
Camera* Player::getCamera()
{
return _camera;
}
bool Player::isAlive()
{
if(_health <= 0)
return false;
return true;
}
int Player::getHealth()
{
return _health;
}
void Player::decreaseHealth()
{
_health -= 1;
}
void Player::decreaseHealth(int damage)
{
switch(damage)
{
case 0:
_health -= 1;
break;
case 1:
_health -= 2;
break;
case 2:
_health -= 5;
break;
case 3:
_health -= 10;
break;
case 4:
_health -= 25;
break;
case 5:
_health -= 50;
break;
default:
_health -= 100;
break;
}
}
void Player::restart()
{
setHealth(100);
_camera->setLocation(Vector3f(0.0f, 0.8f, 0.0f));
}
void Player::increaseHealth()
{
_health += 5;
}
void Player::increaseHealth(int healthPak)
{
_health += healthPak;
}
void Player::setHealth(int health)
{
_health = health;
}