-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTile.cpp
62 lines (46 loc) · 1.16 KB
/
Tile.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
#include "stdafx.h"
#include "Tile.h"
Tile::Tile()
{
this->type = 0;
this->collision = false;
}
Tile::Tile(short type, int grid_x, int grid_y, float gridSizeF,
const sf::Texture& texture, const sf::IntRect& texture_rect, const bool collision)
{
//this->shape.setOutlineThickness(1.f);
//this->shape.setOutlineColor(sf::Color::Black);
this->shape.setPosition(static_cast<float>(grid_x) * gridSizeF, static_cast<float>(grid_y) * gridSizeF);
this->shape.setTexture(texture);
this->shape.setTextureRect(texture_rect);
this->collision = collision;
this->type = type;
}
Tile::~Tile()
{
this->collision = false;
this->type = 0;
}
// Accessors
const short & Tile::getType() const
{
return this->type;
}
const bool & Tile::getCollision() const
{
return this->collision;
}
// Functions
const sf::Vector2f & Tile::getPosition() const
{
return this->shape.getPosition();
}
const sf::FloatRect Tile::getGlobalBounds() const
{
return this->shape.getGlobalBounds();
}
// Functions
const bool Tile::intersects(const sf::FloatRect bounds) const
{
return this->shape.getGlobalBounds().intersects(bounds);
}