-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameEngine.h
53 lines (41 loc) · 1.06 KB
/
GameEngine.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
#pragma once
#include<chrono>
#include <SDL.h>
#include "GridWeb.h"
typedef std::chrono::steady_clock mClock;
typedef enum GameState {MAINMENU, SEARCHING, FREEPLAY, EXIT} GameState;
typedef enum GridMode {G_PLAY, G_FREEZE} GridMode;
const int MILLIS_PER_SECOND = 1000;
class GameEngine {
int SCR_WIDTH;
int SCR_HEIGHT;
int FPS;
int totalFrames;
mClock::time_point sTime;
bool isRunning;
GridMode g_mode;
GameState gameState;
SDL_Thread *updateThread, *drawThread, *searchThread;
SDL_Window *gWindow;
SDL_Renderer *ren;
mClock::time_point lUpdate, lDraw;
Grid *grid; //for drawing
//GridPlayer *gPlayer;
GridWeb *gWeb;
void init(unsigned int gridSize = 50, unsigned int numWorkers = 2);
void initSDL();
void update();
static int updateGame(void* self);
static int renderGame(void* self);
static int searchPatterns(void* self);
bool updateRequired();
bool drawRequired();
void handleEvent(SDL_Event e);
void draw();
public:
GameEngine();
GameEngine(unsigned int GridSize, unsigned int numWorkers);
~GameEngine();
void run();
void quit();
};