-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoardClass.h
74 lines (71 loc) · 2.23 KB
/
BoardClass.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
#pragma once
#include <SFML/Graphics.hpp>
#include <vector>
#include <random>
#include <ctime>
#include "TileClass.h"
using std::string;
using std::vector;
class BoardClass {
public:
BoardClass(int width, int height, int tileSize, int mineCount, sf::RenderWindow& window, string playerName);
void GenerateBoard();
void HandleLeftClick(float x, float y);
void HandleRightClick(float x, float y);
void Draw(sf::RenderWindow& window);
private:
string _playerName;
int _width;
int _height;
int _tileSize;
int _mineCount;
int _flagsPlaced;
sf::Font _font;
sf::RenderWindow& _window;
vector<TileClass> _tiles;
sf::Texture _hiddenTexture;
sf::Texture _revealedTexture;
sf::Texture _flagTexture;
sf::Texture _mineTexture;
vector<sf::Texture> _numberTextures;
void LoadTextures();
sf::Sprite _happyFaceButton;
sf::Texture _happyFaceTexture;
sf::Texture _winFaceTexture;
sf::Texture _loseFaceTexture;
void SetupHappyFaceButton();
void HandleHappyFaceClick();
bool CheckWinCondition();
sf::Texture _counterDigitsTexture;
sf::Texture _counterNegativeTexture;
sf::Vector2f _counterPosition;
void DrawCounter(sf::RenderWindow& window);
sf::Sprite _debugButtonSprite;
sf::Vector2f _debugButtonPosition;
sf::Texture _debugButtonTexture;
bool _debugMode;
sf::Clock _timerClock;
sf::Text _timerText;
sf::Texture _digitsTexture;
vector<sf::Sprite> _digitsSprites;
void DrawTimer(sf::RenderWindow& window);
void DrawDigits(sf::RenderWindow& window, int value, int x, int y);
string GetElapsedTimeAsString() const;
void RestartBoard();
bool _gamePaused;
bool _gameEnded;
sf::Time _pauseTime;
sf::Time _totalElapsedTime;
bool _updateTimer;
sf::Texture _pauseTexture;
sf::Texture _playTexture;
sf::Sprite _pausePlayButton;
void HandlePausePlayButtonClick(float x, float y);
void RevealAdjacentTiles(int x, int y);
sf::Texture _leaderboardTexture;
sf::Sprite _leaderboardButton;
bool _leaderboardOpen;
sf::Time _leaderboardPauseTime;
bool _leaderboardPause;
void HandleLeaderboardClick();
};