Skip to content

Commit

Permalink
Merge pull request #81 from MyEpitech/endGame/victor
Browse files Browse the repository at this point in the history
feat(endGame): add handleWin function
  • Loading branch information
victorpalle authored Jun 3, 2022
2 parents f85bbd0 + 32d7c77 commit 96030a7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions project/Source/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "OptionGameMenuScene.hpp"
#include "BindingScene.hpp"
#include "SelectPlayerScene.hpp"
#include "EndGameScene.hpp"

#include "tools.hpp"
#include "Map.hpp"
Expand Down Expand Up @@ -47,6 +48,7 @@ void Core::loadMenuScenes()
_menuScenes.emplace(Scene::Scenes::OPTION_GAME, std::make_shared<Scene::OptionGameMenuScene>(_settings, _gameSettings));
_menuScenes.emplace(Scene::Scenes::SAVE, std::make_shared<Scene::BindingScene>(_settings, _keyboard, _playerActions, std::bind(&Core::bindKey, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)));
_menuScenes.emplace(Scene::Scenes::SELECT_PLAYER, std::make_shared<Scene::SelectPlayerScene>(_settings, _gameSettings));
_menuScenes.emplace(Scene::Scenes::END_GAME, std::make_shared<Scene::EndGameScene>(_settings, _gameSettings));
//rajouter toutes les scènes des menus
}

Expand Down
2 changes: 2 additions & 0 deletions project/Source/Scenes/GameScenes/EndGameScene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace Scene {
void loadSceneAssets();
void goToMainMenu();
void draw () override;
void fadeBlack() override {};
Scenes handleEvent() override {};

protected:
private:
Expand Down
11 changes: 10 additions & 1 deletion project/Source/Scenes/GameScenes/GameScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Scene::Scenes Scene::GameScene::handleEvent()
player->animation(1);
index++;
}
handleWin();
handleBombs();
return _nextScene;
}
Expand Down Expand Up @@ -219,8 +220,8 @@ void Scene::GameScene::checkIfPlayerIsInRange(std::pair<int, int> const &explosi
for (auto &[index, player] : _players) {
playerPos = _gameMap->transposeFrom3Dto2D(player->getPosition());
if (playerPos == explosionPos) {
std::cout << "died" << std::endl;
player->die();
_players.erase(index);
}
}
}
Expand Down Expand Up @@ -257,6 +258,14 @@ void Scene::GameScene::exploseBomb(Position const &position, int radius)
}
}

void Scene::GameScene::handleWin()
{
// Changement de scene segfault actuellement
// if (_players.size() == 3) {
// _nextScene = Scene::Scenes::END_GAME;
// }
}

void Scene::GameScene::draw()
{
_settings->getCamera()->startMode3D();
Expand Down
2 changes: 2 additions & 0 deletions project/Source/Scenes/GameScenes/GameScene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ namespace Scene {

void checkIfPlayerIsInRange(std::pair<int, int> const &explosionPos);

void handleWin();

protected:
private:
std::shared_ptr<GameSettings> _gameSettings;
Expand Down
3 changes: 2 additions & 1 deletion project/Source/Scenes/IScene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ namespace Scene
END,
OPTION_GAME,
SELECT_MAP,
SELECT_PLAYER
SELECT_PLAYER,
END_GAME
};

enum SOUNDS {
Expand Down

0 comments on commit 96030a7

Please sign in to comment.