-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.cpp
More file actions
49 lines (40 loc) · 763 Bytes
/
Copy pathplayer.cpp
File metadata and controls
49 lines (40 loc) · 763 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
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "player.h"
#include "mastercontrol.h"
#include "inputmaster.h"
Player::Player(int playerId, Context* context): Object(context),
playerId_{playerId},
autoPilot_{false},
alive_{true},
score_{0},
multiplier_{1}
{
}
void Player::Die()
{
alive_ = false;
}
void Player::Respawn()
{
ResetScore();
multiplier_ = 1;
alive_ = true;
}
void Player::SetScore(int points)
{
score_ = points;
}
void Player::ResetScore()
{
SetScore(0);
}
void Player::AddScore(int points)
{
score_ += points;
}
Controllable* Player::GetControllable()
{
Controllable* controllable{ GetSubsystem<InputMaster>()->GetControllableByPlayer(playerId_) };
if (controllable)
return controllable;
else return nullptr;
}