Correction du chargement du niveau
This commit is contained in:
parent
0ea89bdd09
commit
724ba4cf7d
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __PTF_GAME_HPP__
|
#ifndef __PTF_EDITOR_HPP__
|
||||||
#define __PTF_GAME_HPP__
|
#define __PTF_EDITOR_HPP__
|
||||||
|
|
||||||
#include "level.hpp"
|
#include "level.hpp"
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "manager.hpp"
|
#include "manager.hpp"
|
||||||
#include "game.hpp"
|
#include "game.hpp"
|
||||||
|
#include "editor.hpp"
|
||||||
#include "view.hpp"
|
#include "view.hpp"
|
||||||
#include "resource_manager.hpp"
|
#include "resource_manager.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -61,28 +61,27 @@ void Lvl_menu::frame(){
|
||||||
if (event.key.code == sf::Keyboard::Up) {
|
if (event.key.code == sf::Keyboard::Up) {
|
||||||
MoveUp();
|
MoveUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key.code == sf::Keyboard::Down) {
|
if (event.key.code == sf::Keyboard::Down) {
|
||||||
MoveDown();
|
MoveDown();
|
||||||
}
|
}
|
||||||
if (event.key.code == sf::Keyboard::Return) {
|
|
||||||
//si on choisit "tutoriel", on charge le niveau
|
|
||||||
//tutoriel et la vue se met sur Game
|
|
||||||
if(selection==0){
|
|
||||||
std::shared_ptr<Editor> editor = std::shared_ptr<Editor>(new Editor(manager));
|
|
||||||
try {
|
|
||||||
// ouverture du niveau
|
|
||||||
std::ifstream file;
|
|
||||||
file.open("./levels/level1.dat", std::ios::binary | std::ios::in);
|
|
||||||
editor->load(file);
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
} catch (const std::exception& exception) {
|
if (event.key.code == sf::Keyboard::Return) {
|
||||||
std::cerr << "Le programme a quitté après une erreur d'exécution." << std::endl;
|
std::shared_ptr<Game> game = std::shared_ptr<Game>(new Game(manager));
|
||||||
std::cerr << exception.what() << std::endl;
|
std::string path;
|
||||||
}
|
|
||||||
std::shared_ptr<View> game = std::shared_ptr<View>(new Game(manager));
|
switch (selection) {
|
||||||
manager.setView(game);
|
case 0:
|
||||||
|
path = "./levels/level1.dat";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ifstream file;
|
||||||
|
file.open(path, std::ios::binary | std::ios::in);
|
||||||
|
game->load(file);
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
manager.setView(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,4 +93,3 @@ void Lvl_menu::frame(){
|
||||||
window.display();
|
window.display();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue