-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainGame.h
65 lines (50 loc) · 1.62 KB
/
MainGame.h
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
#pragma once
#include <SDL/SDL.h>
#include <GL/glew.h>
#include <GLEngine/Sprite.h>
#include <GLEngine/GLSLProgram.h>
#include <GLEngine/GLTexture.h>
#include <GLEngine/Window.h>
#include <GLEngine/GLEngine.h>
#include <GLEngine/Camera2D.h>
#include <GLEngine/InputManager.h>
#include <GLEngine/Timing.h>
#include <GLEngine/SpriteBatch.h>
#include <vector>
enum class GameState {PLAY, EXIT};
class MainGame
{
public:
MainGame();
~MainGame();
void run();
private:
void initSystems();
void initShaders();
void gameLoop();
void processInput();
void drawGame();
void calculateFPS();
GLEngine::Window _window;
int _screenWidth;
int _screenHeight;
GameState _gameState;
/* Usually, each time we want to load a texture for a sprite, we would manually load that texture, which can lead
* to multiple instance of the texture being loaded.
*
* Texture Cacheing, we want to store textures for use later on. If a sprite needs to use a texture, it will try to find it in cache.
* Texture Cacheing enables us to optimize texture loading, since if it was already loaded, we stored it and can access it.
*
* An array is not the most optimal data structure for texture cacheing, since it would run on O(n).
* A Binary Search Tree is a much better data structure for our purposes, since it's lookup time would be O(log n)
* in C++ this is known as a map */
//std::vector <GLEngine::Sprite*> _sprites; //Deprecated
GLEngine::GLSLProgram _colorProgram;
GLEngine::Camera2D _camera;
GLEngine::SpriteBatch _spriteBatch;
GLEngine::InputManager _inputManager;
GLEngine::FpsLimiter _fpsLimiter;
float _maxfps;
float _fps;
float _time;
};