-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngine.h
More file actions
75 lines (61 loc) · 1.75 KB
/
Copy pathEngine.h
File metadata and controls
75 lines (61 loc) · 1.75 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
#pragma once
#include <memory>
#include <string>
#include "raylib.h"
#include "Game/AbstractGameInstance.h"
#include "Graphics/RenderingHandler.h"
namespace OpenGameCore
{
struct EngineConfig
{
// Window related
int Width = 300;
int Height = Width / 16 * 10;
int Scale = 3;
std::string Title = "Open Game Core";
std::string IconPath = "assets/icon.png";
// Window related
// TODO (LinMAD): Add VSync
bool DisplayFPS = true;
bool HideCursor = false;
};
/**
* @class Engine
* @brief represents a core of game management.
*/
class Engine
{
public:
explicit Engine(EngineConfig cfg = EngineConfig());
~Engine();
/**
* Run game in Engine.
* @param game Implementation
*/
void Run(const std::shared_ptr<AbstractGameInstance>& game);
/**
* Updates Engine and Game state.
*/
void OnUpdate();
/**
* Renders frame on screen.
*/
void OnRender();
public:
/**
* @return Engine instance as singleton.
*/
static Engine& Get();
/**
* @return RenderingHandler.
*/
static std::shared_ptr<RenderingHandler> GetRendingHandler() { return Get().m_RenderingHandler; };
private:
double m_DeltaTime = 0.0; // Time elapsed since the last frame
double m_LastTime = 0.0; // Tracks the last frame's timestamp
EngineConfig m_Config; // TODO (LinMAD): Add config loading and binding via file.
std::shared_ptr<RenderingHandler> m_RenderingHandler;
std::shared_ptr<AbstractGameInstance> m_Game;
Image m_Icon{};
};
} // OpenGameCore