-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapTile.cpp
More file actions
42 lines (35 loc) · 968 Bytes
/
Copy pathMapTile.cpp
File metadata and controls
42 lines (35 loc) · 968 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
36
37
38
39
40
41
42
//
// Created by gpelletier on 2022-02.
//
#include "MapTile.h"
using namespace sf;
using namespace std;
/**
* MapTile constructor
* @param texture_name name of the texture
* @param pos position on map
* @param is_passable is tile passable
* @param is_exit is tile an exit
*/
MapTile::MapTile(const string &texture_name, Vector2f pos, bool is_passable, bool is_exit) :
isPassable(is_passable),
isExit(is_exit),
m_pos(pos) {
SetSprite(texture_name);
}
/**
* Sets the texture, rect and position of a sprite
* @param texture_name
* @return
*/
void MapTile::SetSprite(const string &texture_name) {
if (texture_name.empty() || !m_texture.loadFromFile(texture_name)) {
m_sprite = nullptr;
} else {
m_texture.setSmooth(true);
m_sprite = new Sprite();
m_sprite->setTexture(m_texture);
m_sprite->setTextureRect(IntRect(0, 0, SIZE, SIZE));
m_sprite->setPosition(m_pos);
}
}