-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostGameMenu.cpp
More file actions
80 lines (69 loc) · 2.44 KB
/
Copy pathPostGameMenu.cpp
File metadata and controls
80 lines (69 loc) · 2.44 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "PostGameMenu.h"
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <iostream>
enum class GameState
{
Playing,
GameOver
};
void PostGameMenu::ShowMenu(sf::RenderWindow& window,bool specialmessage)
{
GameState CurrentState = GameState::Playing;
// First, load the font
static sf::Font gameFont;
if (!gameFont.openFromFile("../BELL.ttf")) {
std::cerr << "Failed to load font\n";
}
// Then create text objects with the font directly
float centerpoint=SCREEN_WIDTH/2 - 180;
sf::Text scoreText(gameFont);
scoreText.setCharacterSize(24);
scoreText.setString("Score: "+std::to_string(amt));
scoreText.setFillColor(sf::Color::Blue);
scoreText.setPosition({static_cast<float>(centerpoint*1.5), SCREEN_HEIGHT/2 +50});
sf::Text Author(gameFont);
Author.setCharacterSize(24);
Author.setString("Made By: Nathan Jefferson Honn");
Author.setFillColor(sf::Color::Blue);
Author.setPosition({static_cast<float>(centerpoint*1.25), SCREEN_HEIGHT/2 +90});
sf::Text playAgainText(gameFont);
if (specialmessage==false)
{
playAgainText.setString("Game Over! Press Y to Play Again or N to Quit");
playAgainText.setCharacterSize(24);
playAgainText.setFillColor(sf::Color::Blue);
playAgainText.setPosition({centerpoint*0.85f, SCREEN_HEIGHT/2 + 10});
}
else if (specialmessage==true)
{
playAgainText.setString("YOU WON!!! Press Y to Play Again or N to Quit");
playAgainText.setCharacterSize(24);
playAgainText.setFillColor(sf::Color::Yellow);
playAgainText.setPosition({centerpoint*0.85f, SCREEN_HEIGHT/2 + 10});
}
window.draw(scoreText);
window.draw(playAgainText);
window.draw(Author);
}
void PostGameMenu::ShowPts(sf::RenderWindow& window)
{
static sf::Font gameFont;
if (!gameFont.openFromFile("../BELL.ttf")) {
std::cerr << "Failed to load font\n";
}
static sf::Text ptstxt(gameFont);
static bool initialized = false;
if (!initialized)
{
ptstxt.setCharacterSize(24);
ptstxt.setFillColor(sf::Color(255, 255, 255, 255));
ptstxt.setPosition({10.f, 10.f});
ptstxt.setFillColor(sf::Color::Blue);
initialized = true;
}
// Update the string
ptstxt.setString("Points: " + std::to_string(amt));
// Draw
window.draw(ptstxt);
}