#include <SFML/Graphics.hpp>
#include <SFML/Window/Window.hpp>
#include <fstream>
#include <iostream>
void loadLevel(std::vector<sf::String>& a) {
std::ifstream input;
std::string levelName = "Level1.txt";
input.open(levelName);
if (input.fail()) {
printf("Failed to open level1.txt");
}
std::string temp = "";
while (std::getline(input, temp)) {
a.push_back(temp);
}
}
int main() {
sf::RenderWindow window(sf::VideoMode(600, 400), "SFML works!");
sf::Font font;
if (!font.loadFromFile("arial.ttf")) {
std::cout << "Failed to load font";
}
sf::Text text;
text.setFont(font);
text.setCharacterSize(12);
std::vector<sf::String> bla;
sf::String temp = "";
loadLevel(bla);
for (auto i = 0; i < bla.size(); i++) {
temp += bla[i] + "\n";
}
//this prints correctly
std::cout << static_cast<std::string>(temp);
text.setOrigin(0.f, 0.f);
text.setString(temp);
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(text);
window.display();
}
return 0;
}