Project_Maat/src/Game.cpp

45 lines
850 B
C++
Raw Normal View History

#include <memory>
//
// Created by trotfunky on 06/06/19.
//
#include "Game.h"
Game::Game(const std::vector<std::string>& levels, const std::vector<std::string>& textures)
{
loadTextures();
}
void Game::loadLevel(int levelId)
{
pugi::xml_document document;
pugi::xml_parse_result result = document.load_file(levelFiles.at(levelId).c_str());
if(!result)
{
std::cerr << "Error while loading level :\n" << "\t" << result.description() << std::endl;
exit(-1);
}
currentLevel = std::make_unique<Level>(document,textures);
}
void Game::loadTextures()
{
textures.reserve(textureFiles.size());
for(const std::string& filePath : textureFiles)
{
textures.emplace_back(std::make_unique<sf::Texture>());
textures.back()->loadFromFile(filePath);
}
}
void Game::runGame()
{
}