void Game::draw() {
std::vector<sf::Sprite> sprites;
sf::Sprite temp;
//_levelData is std::multimap, name, sf::Vector2f pair
for (const auto& i : _levelData) {
if (i.first == "Wall") {
temp.setTexture(tree);
temp.setPosition(i.second);
sprites.push_back(std::move(temp));
}
else if (i.first == "Floor") {
temp.setTexture(grass);
temp.setPosition(i.second);
sprites.push_back(std::move(temp));
}
else if (i.first == "Player") {
temp.setTexture(warrior);
temp.setPosition(i.second);
view.setCenter(i.second.x, i.second.y);
_text.setPosition(i.second.x + 13 * 32, i.second.y - 3 * 32);
_text.setString(_level.getStats());
sprites.push_back(std::move(temp));
}
else if (i.first == "Warlock") {
temp.setTexture(warlock);
temp.setPosition(i.second);
sprites.push_back(std::move(temp));
}
else if (i.first == "Monster") {
temp.setTexture(monster);
temp.setPosition(i.second);
sprites.push_back(std::move(temp));
}
else if (i.first == "Brute") {
temp.setTexture(warlock);
temp.setPosition(i.second);
sprites.push_back(std::move(temp));
}
}
if (shouldUpdate) {
_levelData = _level.textToSprite();
shouldUpdate = false;
}
_window.clear();
for (const auto& i : sprites) {
_window.draw(std::move(_text));
_window.draw(std::move(i));
}
_window.setView(view);
_window.display();
}