-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentity.cpp
More file actions
35 lines (28 loc) · 845 Bytes
/
entity.cpp
File metadata and controls
35 lines (28 loc) · 845 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
#include "Entity.hpp"
Entity::Entity(std::string uid, std::string filename, float realX, float realY, int tags) : uid(uid), filename(filename), realX(realX), realY(realY), tags(tags) {
this->tags = tags;
loadSprite(filename);
}
Entity::~Entity() {
}
void Entity::moveToRealXY(float x, float y) {
realX = x;
realY = y;
}
void Entity::loadSprite(std::string filename) {
if (filename != "EMPTY" && !tex.loadFromFile(filename)) {
DEBUG_OUTPUT << "ERROR: Could not load " << filename << std::endl;
return;
};
halfWidth = (int) tex.getSize().x / 2;
height = (int) tex.getSize().y;
spr.setTexture(tex);
spr.setScale(X_SCALE, Y_SCALE);
}
void Entity::render(sf::RenderTarget* screen) {
spr.setPosition(realX - halfWidth, realY - height);
screen->draw(spr);
}
bool Entity::hasTags(int tags) {
return (this->tags & tags) == tags;
}