-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cpp
More file actions
53 lines (44 loc) · 784 Bytes
/
Game.cpp
File metadata and controls
53 lines (44 loc) · 784 Bytes
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
#include <cassert>
#include "Game.h"
#include "raylib.h"
#include "RaylibWrapper.h"
#include "SceneManager.h"
Game::Game(int width, int height, std::string title)
{
assert(!GetWindowHandle());
InitWindow(width, height, title.c_str());
SetTargetFPS(GetMonitorRefreshRate(0));
}
void Game::Init()
{
// Scene Manager
_sceneManager.Init();
}
Game::~Game() noexcept
{
assert(GetWindowHandle());
CloseAudioDevice();
CloseWindow();
}
bool Game::GameShouldClose() const
{
return WindowShouldClose() && !IsKeyPressed(KEY_ESCAPE);
}
void Game::Tick()
{
Update();
BeginDrawing();
// Main Draw
Draw();
EndDrawing();
}
void Game::Update()
{
// Mise a jour du manager de scènes
_sceneManager.Update();
}
void Game::Draw()
{
// Dessine les scènes
_sceneManager.Draw();
}