Started object construction and parsing
Simplified some structures Missing : Entity construction
This commit is contained in:
parent
67435debe6
commit
46d26b6e61
10 changed files with 146 additions and 5 deletions
38
src/Game.cpp
38
src/Game.cpp
|
@ -1,6 +1,44 @@
|
|||
#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()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue