-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cpp
More file actions
105 lines (82 loc) · 1.95 KB
/
Copy pathPlayer.cpp
File metadata and controls
105 lines (82 loc) · 1.95 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// Created by danil on 20.11.2020.
//
#include "Player.h"
Player::Player(sf::Texture& t) {
score = 0;
intimidation = false;
direction_ = Down;
health = 1;
//currentFrame = 0;
sprite.setTexture(t);
rect.width = 20;
rect.height = 20;
rect.left = 20;
rect.top = 20;
speed = 20;
//sprite.scale(1.8, 1.8);
sprite.setTextureRect(sf::IntRect(rect.width,0,rect.width,rect.height));//Âûðåçàåì ñïðàéò
}
Point Player::getPlayerPoint() {
return currentPoint;
}
void Player::goUp() {
currentPoint.y--;
}
void Player::goDown() {
currentPoint.y++;
}
void Player::goLeft() {
currentPoint.x--;
}
void Player::goRight() {
currentPoint.x++;
}
void Player::increaseScore(int value) {
score += value;
}
int Player::getScore() {
return score;
}
void Player::setIntimidation(bool flag) {
intimidation = flag;
}
bool Player::isIntimidation() {
return intimidation;
}
void Player::setDirection(Direction direction) {
direction_ = direction;
}
Direction Player::getDirection() {
return direction_;
}
std::string Player::getColorConsoleTemplate(Map& map) {
std::string colorTemplate = "\x1b[33m";
colorTemplate.push_back(map.getMap()[this->getPlayerPoint().y][this->getPlayerPoint().x]);
colorTemplate += "\x1b[0m";
return colorTemplate;
}
char Player::getHealth() {
return health;
}
void Player::decreaseHealth() {
health--;
}
Point Player::getStartPoint() {
return {START_X_POS,START_Y_POS};
}
void Player::setPlayerPoint(Point& point) {
currentPoint = point;
}
sf::Vector2i Player::getPosInWindow() {
return {currentPoint.x * rect.width, currentPoint.y* rect.height};
}
sf::Sprite Player::getSprite() {
return sprite;
}
sf::IntRect Player::getRect() {
return rect;
}
void Player::setSprite(sf::Vector2i& pos) {
sprite.setPosition(pos.x,pos.y);
}