Line |
Branch |
Exec |
Source |
1 |
|
|
#include "Quit.hpp" |
2 |
|
|
#include "../core/Core.hpp" |
3 |
|
|
|
4 |
|
✗ |
Quit::Quit(Core *core) : _core(core) { |
5 |
|
✗ |
_quitButton = std::make_shared<Button>(sf::Vector2f(100, 500), |
6 |
|
✗ |
sf::Vector2f(100, 100), "Quit", _core->getFont()); |
7 |
|
✗ |
} |
8 |
|
|
|
9 |
|
✗ |
bool Quit::update(sf::Event event, sf::RenderWindow &window) { |
10 |
|
✗ |
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Enter) |
11 |
|
✗ |
window.close(); |
12 |
|
✗ |
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) |
13 |
|
✗ |
_core->_upperState = GameState::DEFAULT; |
14 |
|
✗ |
if (_quitButton->update(event, window)) |
15 |
|
✗ |
window.close(); |
16 |
|
✗ |
return true; |
17 |
|
|
} |
18 |
|
|
|