-
Notifications
You must be signed in to change notification settings - Fork 0
/
board.hpp
67 lines (51 loc) · 1.78 KB
/
board.hpp
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
#ifndef BOARD_H
#define BOARD_H
#include <SFML/Graphics.hpp>
#include <time.h>
class Board {
public: // Initialize the board with the user-provided input
Board();
struct BoardType {
int boardSize, numberOfSpaces, numberOfBombs, potentialMoves;
int **matrix;
bool **clicked;
bool **flags;
std::vector< std::vector<sf::RectangleShape> > spots;
std::vector< std::vector<sf::Text> > numbers;
sf::Font font;
//Style
sf::RectangleShape leftBorder;
sf::RectangleShape rightBorder;
sf::RectangleShape upperBorder;
sf::RectangleShape lowerBorder;
sf::RectangleShape menuBorder;
//Additional style/non-core functionality elements
sf::Text bombCounter;
sf::Text timer;
int time;
bool firstClick;
};
// Asyncronous timer function
void asyncTimer(Board::BoardType *board);
// Initialize the board data structure
void initBoard(Board::BoardType *board);
// For development purposes
void debugBoard(Board::BoardType *board);
// Place the bombs at random
void placeBombs(Board::BoardType *board);
// Initialize the numerical values corresponding to adjacent bombs
void assignValues(Board::BoardType *board);
// Check the games winstate
bool checkWinState(Board::BoardType *board);
// Manages the logic for the humans turn
void bombClicked(Board::BoardType *board, int xpos, int ypos);
// Manage the location of and logic behind flags
void flagPlaced(Board::BoardType *board, int xpos, int ypos);
// Manages the actual move logic
void makeMove(Board::BoardType *board, int row, int column);
// Utility function to determine if a space is on the board. Used to prevent indexing errors in conditional logic
bool checkInBounds(int boardSize, int row, int column);
// Clean up memory (as needed)
void cleanGame(Board::BoardType *board);
};
#endif /* BOARD_H */