2019-06-07 02:59:27 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2019-06-06 21:30:39 +02:00
|
|
|
//
|
|
|
|
// Created by trotfunky on 06/06/19.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Game.h"
|
|
|
|
|
2019-06-07 02:59:27 +02:00
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|