blob: e8d85d6e07a9ce99a809d71e7ac41a82a1edbd73 (
plain)
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
|
#ifndef PUZZLE_HPP_SENTRY
#define PUZZLE_HPP_SENTRY
#include <FL/Enumerations.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Window.H>
#include <string>
#include <vector>
#include <memory>
enum {
puzzle_pieces = 8,
puzzles_per_side = 3,
puzzle_size = 100,
spacing = 5
};
class Puzzle : public Fl_Button{
public:
unsigned char sequence_number;
std::string path;
Puzzle(int x, int y)
: Fl_Button(x, y, puzzle_size, puzzle_size) {}
};
class GameParams {
public:
struct coordinates {
int x, y;
};
private:
coordinates standard_puzzle_coordinates[puzzle_pieces];
char free_puzzles[puzzle_pieces];
coordinates empty_box;
std::vector<std::unique_ptr<Puzzle>> puzzles;
Fl_Window *win;
GameParams(Fl_Window *a_win = nullptr) : win(a_win) {}
void CalculateStandardPuzzlePos();
void ResetFreePuzzles();
void NextUntestedPuzzles();
bool IsSolvability();
void CreateNewPuzzles();
friend class PuzzleGame;
friend void press_button_callback(Fl_Widget*, void*);
public:
void SetXYEmptyBox(int x, int y) { empty_box.x = x; empty_box. y = y; }
coordinates GetXYEmptyBox() { return empty_box; }
static GameParams *SetUpParams(Fl_Window *win) {
GameParams *gi = new GameParams(win);
gi->CalculateStandardPuzzlePos();
gi->SetXYEmptyBox(215, 245);
return gi;
}
};
#endif
|