Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
GameOverScene.cpp
Go to the documentation of this file.
1
9
10namespace rtp::client {
11 namespace scenes {
12
14 Settings& settings,
15 TranslationManager& translationManager,
16 NetworkSyncSystem& network,
17 graphics::UiFactory& uiFactory,
18 std::function<void(GameState)> changeState)
19 : _uiRegistry(UiRegistry),
20 _settings(settings),
21 _translationManager(translationManager),
22 _network(network),
23 _uiFactory(uiFactory),
24 _changeState(changeState)
25 {
26 }
27
29 {
30 log::info("Entering GameOverScene");
31
32 const auto summary = _network.getGameOverSummary();
33 const std::string bestName = summary.bestPlayer.empty() ? "Player" : summary.bestPlayer;
34
37 {468.0f, 160.0f},
38 "GAME OVER",
39 "assets/fonts/title.ttf",
40 64,
41 10,
42 {255, 120, 120}
43 );
44
47 {360.0f, 290.0f},
48 bestName + " has best score " + std::to_string(summary.bestScore),
49 "assets/fonts/main.ttf",
50 22,
51 10,
52 {230, 230, 230}
53 );
54
57 {360.0f, 330.0f},
58 "Your score: " + std::to_string(summary.playerScore),
59 "assets/fonts/main.ttf",
60 20,
61 10,
62 {180, 180, 180}
63 );
64
67 {490.0f, 420.0f},
68 {300.0f, 60.0f},
69 "BACK TO MENU",
70 [this]() {
73 }
74 );
75 }
76
78 {
79 log::info("Exiting GameOverScene");
80 }
81
82 void GameOverScene::handleEvent(const sf::Event& event)
83 {
84 if (const auto* kp = event.getIf<sf::Event::KeyPressed>()) {
85 if (kp->code == sf::Keyboard::Key::Enter ||
86 kp->code == sf::Keyboard::Key::Escape) {
89 }
90 }
91 }
92
93 void GameOverScene::update(float dt)
94 {
95 (void)dt;
96 }
97
98 } // namespace scenes
99} // namespace rtp::client
System to handle network-related operations on the client side.
void tryLeaveRoom(void)
Send a request to leave the current room on the server.
GameOverSummary getGameOverSummary(void) const
Manages game settings and preferences.
Definition Settings.hpp:67
Manages game translations for all UI elements.
Factory class for creating UI components in the ECS registry.
Definition UiFactory.hpp:72
static ecs::Entity createText(ecs::Registry &registry, const position &position, const std::string &content, const std::string &fontPath, unsigned int fontSize, const std::uint8_t zIndex=0, const color &textColor={255, 255, 255})
Definition UiFactory.cpp:43
static ecs::Entity createButton(ecs::Registry &registry, const position &position, const size &size, const std::string &label, std::function< void()> onClick=nullptr)
Create a button UI component.
Definition UiFactory.cpp:17
void onEnter(void) override
Called when the scene is entered.
void onExit(void) override
Called when the scene is exited.
void update(float dt) override
Update the scene state.
void handleEvent(const sf::Event &event) override
Handle an incoming event.
GameOverScene(ecs::Registry &UiRegistry, Settings &settings, TranslationManager &translationManager, NetworkSyncSystem &network, graphics::UiFactory &uiFactory, std::function< void(GameState)> changeState)
R-Type client namespace.
@ Menu
Main menu state.
void info(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log an informational message.