-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCandyBoard.h
67 lines (62 loc) · 1.81 KB
/
CandyBoard.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
#include <vector>
#ifndef CANDY_H
#define CANDY_H
#include "Candy.h"
#endif // CANDY_H
enum DIRECTION
{
LEFT,
UP,
RIGHT,
DOWN,
VERTICAL,
HORIZONTAL
};
class CandyBoard
{
public:
CandyBoard(int = 9, int = 9);
//CandyBoard(int rows, int columns);
~CandyBoard();
void handleEvent(SDL_Event* e);
void fallingBoard(SDL_Renderer* lRenderer);
int reIndex();
void sugarCrush();
void generateRandomBoard();
int countPossibleMove();
// count match in particular direction
// direction can be one of the 4 DIRECTION
int countMatchInDirection(int x, int y, DIRECTION direction);
// for coordinate instead of board position
int countMatchInDirectionCoord(int cx, int cy, DIRECTION direction);
// return the number of candies deleted
int deleteMatchInDirectionCoord(int cx, int cy, DIRECTION direction);
int deleteMatchInDirection(int lX, int lY, DIRECTION direction);
int deleteBySpecialCandy(Candy* );
int deleteByColourBomb(Candy* );
void displayCandyBoard(SDL_Renderer* lRenderer);
// -1: if there is already a match
// n: number of potential matches
int getBoardWidth();
int getBoardHeight();
int getX();
int getY();
// to avoid logic error
Candy* getCandy(int x, int y);
Candy* getCandyCoord(int x,int y);
int getPositionX(int );
int getPositionY(int );
private:
int multiplier;
int mCascadeCounter;
const int LEAST_POSSIBLE_MOVES;
// for board texture - the grid containing the candies
Texture boardTexture;
// need to be more dynamic
std::vector< std::vector<Candy> >candies;
SDL_Point last_candy_choosen;
int mRows, mColumns;
int mWidth, mHeight;
// coordinate of up left corner
int mX, mY;
};