-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** zappy | ||
** File description: | ||
** WinScene | ||
*/ | ||
|
||
#include "WinScene.hpp" | ||
#include "../core/Core.hpp" | ||
|
||
WinScene::WinScene(Core *core) | ||
{ | ||
_text.setFont(core->getFont()); | ||
_text.setCharacterSize(25); | ||
_text.setFillColor(sf::Color::White); | ||
_core = core; | ||
_quitButton = std::make_shared<Button>(sf::Vector2f(100, 500), sf::Vector2f(100, 100), "Quit", _core->getFont()); | ||
_homeButton = std::make_shared<Button>(sf::Vector2f(100, 450), sf::Vector2f(100, 100), "Home", _core->getFont()); | ||
_homeButton->setCallBack(std::bind(&WinScene::getBackHome, this)); | ||
_win = std::make_shared<Sprite>("./assets/win.png"); | ||
_win->setScale(1.5f); | ||
} | ||
|
||
void WinScene::draw(sf::RenderWindow &window) | ||
{ | ||
sf::Vector2f winSize = window.getView().getSize(); | ||
_quitButton->setPosition(sf::Vector2f(winSize.x / 2 - 150, winSize.y / 2 + 150)); | ||
_homeButton->setPosition(sf::Vector2f(winSize.x / 2 + 50, winSize.y / 2 + 150)); | ||
_quitButton->draw(window); | ||
_homeButton->draw(window); | ||
_text.setPosition(sf::Vector2f(winSize.x / 2 -_text.getGlobalBounds().width / 2 | ||
, winSize.y / 2 + 100)); | ||
_text.setString(_core->_winner + " won the game !"); | ||
_win->setPosition(sf::Vector2f(winSize.x / 2, winSize.y / 2 - 100)); | ||
window.draw(_text); | ||
_win->draw(window); | ||
} | ||
|
||
void WinScene::getBackHome() | ||
{ | ||
if (_core->_server.disconectFromServer() == true) | ||
_core->_data.resetGame(); | ||
_core->_upperState = GameState::DEFAULT; | ||
_core->_state = GameState::HOME; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** zappy | ||
** File description: | ||
** WinScene | ||
*/ | ||
|
||
#ifndef WINSCENE_HPP_ | ||
#define WINSCENE_HPP_ | ||
|
||
#include <memory> | ||
|
||
#include "IScene.hpp" | ||
#include "../ui/Button.hpp" | ||
#include "../ui/Input.hpp" | ||
#include "../sprites/Sprite.hpp" | ||
|
||
class Core; | ||
|
||
class WinScene : public IScene { | ||
public: | ||
WinScene(Core *core); | ||
~WinScene() { | ||
|
||
} | ||
|
||
bool update(sf::Event event, sf::RenderWindow &window) override | ||
{ | ||
if (_quitButton->update(event, window)) | ||
window.close(); | ||
_homeButton->update(event, window); | ||
return false; | ||
} | ||
|
||
void update(float /*fElapsedTime*/) override | ||
{ | ||
|
||
} | ||
|
||
void draw(sf::RenderWindow &window) override; | ||
|
||
void init() override | ||
{ | ||
|
||
} | ||
|
||
void getBackHome(); | ||
protected: | ||
private: | ||
Core *_core; | ||
std::shared_ptr<Button> _homeButton; | ||
std::shared_ptr<Button> _quitButton; | ||
sf::Text _text; | ||
std::shared_ptr<Sprite> _win; | ||
|
||
}; | ||
|
||
#endif /* !WINSCENE_HPP_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters