-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTile.cpp
68 lines (51 loc) · 1.19 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
63
64
65
66
67
68
#include "stdafx.h"
#include "Tile.h"
//Constructors and Destructor:
Tile::Tile()
{
this->type = 0;
this->collision = false;
}
Tile::Tile
(
int type,
int grid_x, int grid_y, float grid_size_f,
const sf::Texture& texture, const sf::IntRect& texture_rect,
const bool collision
)
{
// this->shape.setSize(sf::Vector2f(grid_size_f, grid_size_f));
// this->shape.setFillColor(sf::Color::White);
// this->shape.setOutlineThickness(1.f);
// this->shape.setOutlineColor(sf::Color::Black);
this->type = type;
this->collision = collision;
this->shape.setPosition(static_cast<float>(grid_x) * grid_size_f, static_cast<float>(grid_y) * grid_size_f);
this->shape.setTexture(texture);
this->shape.setTextureRect(texture_rect);
}
Tile::~Tile()
{
}
//Accessors:
const int& Tile::getType() const
{
return this->type;
}
const bool& Tile::getCollision() const
{
return this->collision;
}
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);
}