-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.h
126 lines (101 loc) · 2.19 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#pragma once
#include <vector>
#include "LoadTex.h"
#include "LoadTimer.h"
class Cell
{
public:
Cell();
~Cell();
bool CheckMine();
void SetMine();
void IncrementMineCount();
int ReadMineCount();
bool checkOpened();
void setOpened();
void toggleFlagged();
bool checkFlagged();
void resetCell();
SDL_Rect CellLocation;
private:
bool isMine;
bool isOpened;
bool isFlagged;
int MineCount;
};
enum Difficulty : int
{
EASY,
NORMAL,
HARD
};
class Game
{
public:
Game();
~Game();
//game generation
void GenerateBoard();
void GenerateMines();
void GenerateNumbers();
void SetDifficulty();
// renderer/event stuff
void SelectRenderer(SDL_Renderer &renderer);
void selectEventSystem(SDL_Event &eventSystem);
//Loading
void LoadObjects();
void RunRenderer();
void RunEvents();
void Update();
//game logic
void OpenCells();
void FlagCells();
void ChordCells();
void AutoFillCheck();
void ResetGame();
void FailureCheck();
void Success();
bool optionsSelected;
Difficulty gameDifficulty;
private:
//Minesweeper board
int gridSizeX;
int gridSizeY;
int TotalMines;
int FlaggedCount;
//vector of vectors based off of gridsizeX, gridsizeY
std::vector<std::vector<Cell>> gameBoard;
//game specific variables
bool fail;
bool win;
bool firstClick;
//Required stuff to get renderer and game functions going.
//gameRenderer: Which renderer to render to? getRenderer will ask where to output this data on initialization.
//gameEvent: What event system to use? gets the event system and uses it within scope
SDL_Renderer *gameRenderer;
SDL_Event* gameEvent;
//Mouse
int mouseX = 0;
int mouseY = 0;
//Objects called in scene
Sprite MineSkin;
Sprite MouseHover;
//UI
Sprite NewGameButton;
Sprite NewGameButtonPressed;
Sprite ButtonHover;
Sprite OptionsButton;
Sprite OptionsPressed;
Sprite OptionsHover;
Sprite UI;
//Font - OFL-Licensed Press Start 2P
TTF_Font* gameFont;
Texture fntMinesLeft;
Texture fntTime;
//Timer - Clock time for Minesweeper
LoadTimer gameTime;
//TODO: in Sprite class, make a tex_location so that Cell Location and button location don't have to be manually done.
SDL_Rect NewGameButtonLoc;
SDL_Rect OptionsButtonLoc;
SDL_Rect UILoc;
};