StevEngine
StevEngine is a customizable C++ game engine.
Loading...
Searching...
No Matches
Engine.hpp
1#pragma once
2#include "EventSystem.hpp"
3#include <SDL.h>
4#include <sys/types.h>
5
6namespace StevEngine {
10 struct GameSettings {
11 #ifdef StevEngine_SHOW_WINDOW
12 bool vsync = false;
13 bool fullscreen = false;
14 u_int16_t MSAA = 4;
15 int WIDTH = 800;
16 int HEIGHT = 600;
17 #endif
18 int targetFPS = 60;
19 };
20
27 class Engine {
28 public:
34 Engine(std::string title, GameSettings gameSettings);
35
40 int Start();
41
42 #ifdef StevEngine_SHOW_WINDOW
43 SDL_Window* window;
44 #endif
45
50 EventManager* GetEvents() { return &events; };
51
56 double getFPS() const;
57
58 bool running;
59
61 const std::string title;
62
67 GameSettings GetGameSettings() const { return gameSettings; }
68
73 void SetSettings(GameSettings gameSettings);
74
79 void SetTargetFPS(int targetFPS);
80
81 #ifdef StevEngine_SHOW_WINDOW
86 void SetVSync(bool vsync);
87
92 void SetFullscreen(bool fullscreen);
93
99 void SetWindowSize(int width, int height);
100 #endif
101
102 private:
103 EventManager events;
104 double currentFPS;
105 SDL_Event ev;
106 GameSettings gameSettings;
107
108 #ifdef StevEngine_PLAYER_DATA
112 void SetGameSettingsFromFile();
113 #endif
114 };
115
117 extern Engine* engine;
118
124 void CreateEngine(std::string title = "Game", GameSettings gameSettings = GameSettings());
125}
void SetSettings(GameSettings gameSettings)
Update engine settings.
Definition Engine.cpp:190
Engine(std::string title, GameSettings gameSettings)
Create engine instance.
Definition Engine.cpp:30
void SetWindowSize(int width, int height)
Set window size.
Definition Engine.cpp:239
bool running
Whether engine is running.
Definition Engine.hpp:58
void SetFullscreen(bool fullscreen)
Set fullscreen mode.
Definition Engine.cpp:219
void SetTargetFPS(int targetFPS)
Set target FPS.
Definition Engine.cpp:203
int Start()
Start engine main loop.
Definition Engine.cpp:69
void SetVSync(bool vsync)
Set vertical sync.
Definition Engine.cpp:211
const std::string title
Game window title.
Definition Engine.hpp:61
double getFPS() const
Get current FPS.
Definition Engine.cpp:252
GameSettings GetGameSettings() const
Get current engine settings.
Definition Engine.hpp:67
EventManager * GetEvents()
Get engine event manager.
Definition Engine.hpp:50
SDL_Window * window
Main game window.
Definition Engine.hpp:43
Manages event subscriptions and publishing.
Definition EventSystem.hpp:74
Engine configuration settings.
Definition Engine.hpp:10
int HEIGHT
Window height.
Definition Engine.hpp:16
int targetFPS
Target frames per second (-1 for unlimited)
Definition Engine.hpp:18
u_int16_t MSAA
Multisample anti-aliasing samples.
Definition Engine.hpp:14
bool fullscreen
Whether to run fullscreen.
Definition Engine.hpp:13
int WIDTH
Window width.
Definition Engine.hpp:15
bool vsync
Whether to use vertical sync.
Definition Engine.hpp:12