-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cpp
108 lines (102 loc) · 3.06 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
97
98
99
100
101
102
103
104
105
106
107
108
#include "Player.h"
Player::Player(int _X, int _Y)
: x(_X), y(_Y), hp(20), hpMax(20), ultCharge(0), ultMax(20), shieldCharge(0), shieldMax(25)
{
texture.loadFromFile("Assets/Chara/boat.png");
shielded_boat.loadFromFile("Assets/chara/shielded_boat.png");
sprite.setScale(2, 2);
sprite.setPosition(_X, _Y);
texture_atk1.loadFromFile("Assets/Projectile/orbe_joueur.png");
font.loadFromFile("Assets/Font/pixel.ttf");
text.setFont(font);
text.setFillColor(Color::Black);
text.setPosition(0, 17);
isShielded = false;
}
void Player::setSprite() {
if (isShielded == true) {
sprite.setTexture(shielded_boat);
}
else sprite.setTexture(texture);
}
void Player::setPos(int x, int y) {
sprite.setPosition(x, y);
}
void Player::setHp(int i) { hp = i; }
void Player::increaseShield(int i) {
if (shieldCharge < 25) {
if (shieldClock.getElapsedTime().asSeconds() > 1.f) {
shieldCharge += 1;
cout << shieldCharge << endl;
shieldClock.restart();
}
}
}
void Player::decreaseShield(int i) {
shieldClock.restart();
shieldCharge = 0;
}
void Player::decreaseUlt(int i) {
ultClock.restart();
ultCharge -= 1;
}
void Player::increaseUlt(int i) {
if (ultCharge < 60) {
if (ultClock.getElapsedTime().asSeconds() > 1.f) {
ultCharge += 5;
cout << " ultcharge:" << ultCharge << endl;
ultClock.restart();
}
}
}
void Player::decreaseHp(int i) {
hp -= i;
}
void Player::increaseHp(int i) {
hp += i;
}
void Player::decreaseHpMax(int i) {
hpMax -= i;
}
void Player::increaseHpMax(int i) {
hpMax += i;
}
void Player::draw(RenderWindow& window) {
window.draw(sprite);
}
void Player::move(Vector2f distance) {
sprite.move(distance);
}
void Player::bomb() {
}
void Player::enableShield() {isShielded = true;}
void Player::disableShield() { isShielded = false; }
void Player::enableUltimate() {isUlti = true;}
void Player::disableUltimate() {isUlti = false;}
void Player::increaseScore(int i) {
score += i;
}
void Player::decreaseScore(int i) {
score -= i;
}
void Player::drawScore(RenderWindow& window) {
text.setString("Score : " + to_string(score));
window.draw(text);
}
bool Player::isCollidingEnemy() const {
if (sprite.getGlobalBounds().intersects(enemy->sprite.getGlobalBounds())) return true;
else return false;
}
bool Player::getIsUlt() const { return isUlti; }
void Player::setShield(int i) { shieldCharge = i; }
void Player::setMoveSpeed(float i) { moveSpeed = i; }
int Player::getScore() const { return score; }
int Player::getShieldCharge() const { return shieldCharge; }
float Player::getHP() const { return hp; }
float Player::getHPMax() const { return hpMax; }
float Player::getUlt() const { return ultCharge; }
float Player::getUltMax() const { return ultMax; }
bool Player::getIsShielded() const { return isShielded; }
int Player::getShieldMax() const { return shieldMax; }
float Player::getMoveSpeed() const { return moveSpeed; }
Vector2f Player::getPos() const { return sprite.getPosition(); }