-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpause-state.cpp
More file actions
49 lines (39 loc) · 1.09 KB
/
Copy pathpause-state.cpp
File metadata and controls
49 lines (39 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "pause-state.hpp"
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "state.hpp"
PauseState::PauseState(std::shared_ptr<sf::RenderWindow> window, std::shared_ptr<State::StateID> stateUpdater) : State(window, stateUpdater)
{
sf::Vector2u windowSize = window_->getSize();
pause_.setString("Pause");
pause_.setFont(font_);
pause_.setFillColor(sf::Color::Magenta);
pause_.setCharacterSize(70);
pause_.setOrigin((pause_.getLocalBounds().width / 2.0f), (pause_.getLocalBounds().height / 2.0f));
pause_.setPosition(windowSize.x / 2.0f, windowSize.y / 2.0f);
}
void PauseState::handleEvents()
{
sf::Event event;
while (window_->pollEvent(event))
{
if (event.type == sf::Event::EventType::Closed)
{
window_->close();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::P) || sf::Keyboard::isKeyPressed(sf::Keyboard::Enter))
{
*stateUpdater_ = StateID::PLAY;
}
}
}
void PauseState::update(sf::Time deltaTime)
{
}
void PauseState::render()
{
window_->clear();
window_->draw(background_);
window_->draw(pause_);
window_->display();
}