-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameOverPlayState.cpp
More file actions
65 lines (52 loc) · 1.47 KB
/
GameOverPlayState.cpp
File metadata and controls
65 lines (52 loc) · 1.47 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "GameOverPlayState.h"
#include "PlayDriverState.h"
#include "Event.h"
#include "EventQueue.h"
#include "Config.h"
#include <SFML/Graphics/RenderTarget.hpp>
GameOverPlayState::GameOverPlayState(PlayDriverState &play) :
PlayState(play),
optionSelector_()
{}
void GameOverPlayState::update(float deltaTime)
{
optionSelector_.update(deltaTime);
}
void GameOverPlayState::updateOnMouseMove(int mouseX, int mouseY)
{
const float invGameScale = 1.0f / Config::Game::scale;
sf::Vector2f scaledMousePosition(
mouseX * invGameScale,
mouseY * invGameScale);
optionSelector_.updateOnMouseMove(
scaledMousePosition + play_.camera_.getPosition());
}
void GameOverPlayState::updateOnMouseButtonPress(sf::Mouse::Button button)
{
optionSelector_.updateOnMouseButtonPress(button);
}
void GameOverPlayState::updateOnKeyPress(sf::Keyboard::Key key)
{
// Escaping to Main Menu is already handled by PlayDriverState::updateOnKeyPress
if (key == sf::Keyboard::Key::R)
{
EventQueue::getInstance().send(
new EventChangeDriverState(
DriverStateType::Play));
}
else
{
optionSelector_.updateOnKeyPress(key);
}
}
void GameOverPlayState::draw(sf::RenderTarget &target, sf::RenderStates states) const
{
states.transform.scale(
sf::Vector2f(
Config::Game::scale,
Config::Game::scale));
states.transform.translate(-play_.camera_.getPosition());
target.draw(play_.arenaSprite_, states);
target.draw(play_.scoreInterface_, states);
target.draw(optionSelector_, states);
}