Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Tile.h"
- #include "SFML/System/Vector2.hpp"
- #include "SFML/Graphics/Color.hpp"
- const float Tile::TILE_SIZE = 48.0f;
- Tile::Tile(float cx, float cy, int type, bool traversable) {
- this->cx = cx;
- this->cy = cy;
- this->type = type;
- this->traversable = traversable;
- this->shape = sf::RectangleShape(sf::Vector2f(Tile::TILE_SIZE, Tile::TILE_SIZE));
- this->shape.setPosition(sf::Vector2f((cx - (Tile::TILE_SIZE / 2)), (cy - (Tile::TILE_SIZE / 2))));
- this->shape.setFillColor((type == 0)?(sf::Color::White):(sf::Color::Blue));
- }
- Tile::~Tile() {
- }
- int Tile::GetType() {
- return this->type;
- }
- void Tile::SetType(int type) {
- this->type = type;
- if(type == 0) {
- this->traversable = true;
- this->shape.setFillColor(sf::Color::White);
- } else {
- this->traversable = false;
- this->shape.setFillColor(sf::Color::Blue);
- }
- }
- bool Tile::IsTraversable() {
- return this->traversable;
- }
- void Tile::Draw(sf::RenderWindow* window) {
- window->draw(this->shape);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement