Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
MenuScene.hpp
Go to the documentation of this file.
1
8#ifndef RTYPE_CLIENT_SCENES_MENUSCENE_HPP_
9 #define RTYPE_CLIENT_SCENES_MENUSCENE_HPP_
10
11 #include "Interfaces/IScene.hpp"
12 #include "RType/ECS/Registry.hpp"
13 #include "UI/UiFactory.hpp"
14 #include "Utils/GameState.hpp"
15 #include "Systems/NetworkSyncSystem.hpp"
17 #include "Core/Settings.hpp"
18 #include <SFML/Graphics.hpp>
19 #include <memory>
20 #include <functional>
21 #include <vector>
22
23namespace rtp::client {
24 class EntityBuilder;
25
26 namespace scenes {
36 {
37 public:
45 MenuScene(ecs::Registry& UiRegistry,
46 ecs::Registry& worldRegistry,
47 Settings& settings,
48 TranslationManager& translationManager,
49 NetworkSyncSystem& network,
50 graphics::UiFactory& uiFactory,
51 EntityBuilder& worldEntityBuilder,
52 std::function<void(GameState)> changeState);
53
57 using ChangeStateFn = std::function<void(GameState)>;
58
62 void onEnter(void) override;
63
67 void onExit(void) override;
68
73 void handleEvent(const sf::Event& event) override;
74
79 void update(float dt) override;
80
81 private:
82 struct MenuEnemy {
84 float speed;
85 float baseY;
86 float amplitude;
87 float frequency;
88 float phase;
89 float resetX;
90 };
91
101 std::vector<ecs::Entity> _menuWorldEntities;
102 std::vector<MenuEnemy> _menuEnemies;
103 float _menuTime{0.0f};
107 void updateWeaponDisplay();
108 };
109 } // namespace scenes
110} // namespace rtp::client
111
112#endif // RTYPE_CLIENT_SCENES_MENUSCENE_HPP_
System to handle network-related operations on the client side.
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
Interface for different scenes in the client application.
Definition IScene.hpp:23
Scene for the main menu.
Definition MenuScene.hpp:36
ecs::Entity _weaponNameText
Entity for weapon name display.
std::vector< MenuEnemy > _menuEnemies
Moving enemies for menu decor.
float _menuTime
Menu animation timer.
NetworkSyncSystem & _network
Reference to the client network.
Definition MenuScene.hpp:96
ChangeStateFn _changeState
Function to change the game state.
Definition MenuScene.hpp:99
std::function< void(GameState)> ChangeStateFn
Type alias for a function that changes the game state.
Definition MenuScene.hpp:57
TranslationManager & _translationManager
Reference to the translation manager.
Definition MenuScene.hpp:95
EntityBuilder & _worldEntityBuilder
World entity builder for menu visuals.
Definition MenuScene.hpp:98
graphics::UiFactory & _uiFactory
UI Factory for creating UI components.
Definition MenuScene.hpp:97
Settings & _settings
Reference to the application settings.
Definition MenuScene.hpp:94
ecs::Registry & _worldRegistry
Reference to the world ECS registry.
Definition MenuScene.hpp:93
std::vector< ecs::Entity > _menuWorldEntities
Menu background entities.
void onEnter(void) override
Called when the scene is entered.
Definition MenuScene.cpp:45
void handleEvent(const sf::Event &event) override
Handle an incoming event.
ecs::Entity _weaponStatsText
Entity for weapon stats display.
void onExit(void) override
Called when the scene is exited.
ecs::Registry & _uiRegistry
Reference to the ECS registry.
Definition MenuScene.hpp:92
ecs::Entity _menuMusicEntity
Entity for menu background music.
void updateWeaponDisplay()
Update weapon name and stats texts.
void update(float dt) override
Update the scene state.
Represents an entity in the ECS (Entity-Component-System) architecture.
Definition Entity.hpp:63
R-Type client namespace.