#include "floor.hpp" #include #include #include #include #include #include #include "tileset.hpp" namespace silly::editor { void TileFloor::render(sf::RenderWindow &window) const { std::for_each(this->tiles.begin(), this->tiles.end(), [&window](const Tile &t) { sf::Sprite s(t.tile->texture); s.setPosition({t.position.x * (float)TILE_WIDTH, t.position.y * (float)TILE_HEIGHT}); window.draw(s); }); } void TileFloor::place_tile(std::shared_ptr &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, tile}); } } 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; } }