-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.h
76 lines (60 loc) · 1.46 KB
/
Game.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
65
66
67
68
69
70
71
72
73
74
75
76
/// \file Game.h
/// \brief Contains Point enumeration Coordinate class and Game singleton
///
#ifndef GAME_H
#define GAME_H
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include "GameException.h"
/// \brief Describes what is on the point (intersection)
///
typedef enum _point {EMPTY, BLACK, WHITE} Point;
/// \brief Holds coordinates of a point on board, but also can contain pixel coordinates.
/// Origin is at the top left corner in either case. Columns numbered from left to right 0-18, rows numbered from top to bottom 0-18.
/// Or from 0 to window size when it holds pixels.
///
class Coordinate
{
public:
int col;
int row;
Coordinate():col(0), row(0) {}
Coordinate(int c, int r):col(c), row(r) {}
bool operator==(Coordinate pos)
{
return (this->col == pos.col) && (this->row == pos.row);
}
};
/// \brief Game singleton holds necessary variables/functions for initiating SDL2
///
class Game
{
public:
static Game* instance;
static Game* createInstance()
{
if(instance == NULL)
{
instance = new Game();
return instance;
}
return NULL;
}
SDL_Renderer * const getRenderer()
{
return renderer;
}
SDL_Window * const getWindow()
{
return window;
}
~Game();
protected:
private:
Game();
const int winWidth, winHeight;
SDL_Renderer *renderer;
SDL_Window *window;
};
#endif // GAME_H