-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntity.cpp
More file actions
73 lines (49 loc) · 1.25 KB
/
Entity.cpp
File metadata and controls
73 lines (49 loc) · 1.25 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
//
// Created by segalle on 08/11/2021.
//
#include "Entity.h"
namespace entities{
Entity::Entity() : Being(),
sprite(nullptr),
position(0, 0),
alive(true)
{}
Entity::~Entity() {
sprite = assets->getSprite("failedTexture");
}
void Entity::setSprite(sf::Sprite *sprite) {
this->sprite = sprite;
}
void Entity::setPosition(sf::Vector2f position) {
this->position = position;
}
void Entity::setPosition(float x, float y) {
position.x = x;
position.y = y;
}
const sf::Vector2f Entity::getPosition() const {
return position;
}
sf::Sprite *Entity::getSprite() {
sprite->setPosition(position);
return sprite;
}
float Entity::getFeetPosition() {
return sprite->getPosition().y + sprite->getGlobalBounds().height;
}
void Entity::setFeetPosition(float feet_position) {
position.y = feet_position - sprite->getGlobalBounds().height;
}
void Entity::die() {
alive = false;
}
bool Entity::getIsAlive(){
return alive;
}
void Entity::move(sf::Vector2f amount) {
position += amount;
}
void Entity::setIsAlive(bool isAlive){
alive = isAlive;
}
}