-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEndGame.cpp
More file actions
52 lines (44 loc) · 1.87 KB
/
EndGame.cpp
File metadata and controls
52 lines (44 loc) · 1.87 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
#include "EndGame.h"
EndGame::EndGame(sf::RenderWindow& window, sf::Font& font, std::string end_game_message)
: font(font)
{
background.setSize(sf::Vector2f(static_cast<float>(window.getSize().x), static_cast<float>(window.getSize().y)));
background.setFillColor(sf::Color(20, 20, 20, 100));
container.setSize(sf::Vector2f(static_cast<float>(window.getSize().x) / 2.f, static_cast<float>(window.getSize().y) - 100.f));
container.setFillColor(sf::Color(20, 20, 20, 150));
container.setPosition(static_cast<float>(window.getSize().x) / 2.f - container.getSize().x / 2.f, 30.f);
menuText.setFont(font);
menuText.setFillColor(sf::Color(255, 255, 255, 200));
menuText.setCharacterSize(60);
menuText.setString(end_game_message);
menuText.setPosition(container.getPosition().x + container.getSize().x / 2.f - menuText.getGlobalBounds().width / 2.f, container.getPosition().y + 40.f);
float buttonWidth = 300.f;
float buttonHeight = 80.f;
float buttonX = container.getPosition().x + container.getSize().x / 2.f - buttonWidth / 2.f;
float buttonY = container.getPosition().y + container.getSize().y / 2.f - buttonHeight / 2.f;
button = new Button(
buttonX, buttonY, buttonWidth, buttonHeight,
&this->font, "Exit", 60,
sf::Color(70, 70, 70, 200), sf::Color(250, 250, 250, 250), sf::Color(20, 20, 20, 50),
sf::Color(70, 70, 70, 0), sf::Color(150, 150, 150, 0), sf::Color(20, 20, 20, 0)
);
}
EndGame::~EndGame()
{
delete button;
}
const bool EndGame::isButtonPressed()
{
return button->isPressed();
}
void EndGame::update(const sf::Vector2f& mousePos)
{
button->update(mousePos);
}
void EndGame::render(sf::RenderTarget& target)
{
target.draw(background);
target.draw(container);
button->render(&target);
target.draw(menuText);
}