-
Notifications
You must be signed in to change notification settings - Fork 19
/
player.cpp
96 lines (81 loc) · 1.64 KB
/
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
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
85
86
87
88
89
90
91
92
93
94
95
96
#include "player.h"
#include <iostream>
Player::Player(int x, int y, int currentHealth, int maxHealth)
{
x_ = x;
y_ = y;
speed_ = 3;
xdir_ = 0;
ydir_ = 0;
image_.load(":img/player.png");
healthBarImage_.load("img/playerHealthBar.png");
healthBarBackgroundImage_.load("img/playerHealthBarBackground.png");
rect_ = image_.rect();
health_ = currentHealth;
maxHealth_ = maxHealth;
healthBarColor_ = qRgb(6, 113, 220);
healthBarColor_.setAlpha(204);
healthBarBorderColor_ = qRgb(124, 179, 242);
powerBarColor_ = qRgb(159, 10, 245);
powerBarColor_.setAlpha(180);
powerBarBorderColor_ = qRgb(78, 6, 120);
power_ = maxPower;
maxPower_ = power_;
}
Player::~Player()
{
}
void Player::moveLeft(int speed)
{
x_ -= speed;
}
void Player::moveRight(int speed)
{
x_ += speed;
}
void Player::moveUp(int speed)
{
y_ -= speed;
}
void Player::moveDown(int speed)
{
y_ += speed;
}
void Player::resetState(int x, int y)
{
x_ = x;
y_ = y;
health_ = maxHealth_;
}
void Player::setMaxPower(int maxPower)
{
maxPower_ = maxPower;
}
int Player::getPower()
{
return power_;
}
int Player::getMaxPower()
{
return maxPower_;
}
void Player::modifyPower(int amount)
{
power_ += amount;
}
QColor Player::getPowerBarColor()
{
return powerBarColor_;
}
QColor Player::getPowerBarBorderColor()
{
return powerBarBorderColor_;
}
QImage Player::getPowerBarImage()
{
return powerBarImage_;
}
QImage Player::getPowerBarBackgroundImage()
{
return powerBarBackgroundImage_;
}