#include "floor.hpp" #include #include #include #include #include namespace silly::editor { void TileFloor::render(sf::RenderWindow &window) const { std::for_each( this->tiles.begin(), this->tiles.end(), [&window](const Tile &t) { sf::RectangleShape shape({16, 16}); shape.setFillColor(sf::Color(255, 190, 190)); shape.setPosition({t.position.x * 16.0f, t.position.y * 16.0f}); window.draw(shape); }); } void TileFloor::place_tile(const sf::Vector2i &position) { if (!std::any_of( this->tiles.begin(), this->tiles.end(), [&position](const Tile &t) { return t.position == position; })) { this->tiles.push_back({position}); } } void TileFloor::remove_tile(const sf::Vector2i &position) { this->tiles.resize(std::distance( this->tiles.begin(), std::remove_if( this->tiles.begin(), this->tiles.end(), [&position](const Tile &t) { return t.position == position; }))); } const int TileFloor::get_width() const { return this->width; } const int TileFloor::get_height() const { return this->height; } }