back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/puzzle.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'puzzle.hpp')
-rw-r--r--puzzle.hpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/puzzle.hpp b/puzzle.hpp
index 09660c8..88f13ac 100644
--- a/puzzle.hpp
+++ b/puzzle.hpp
@@ -17,15 +17,21 @@ enum {
};
class Puzzle : public Fl_Button{
-public:
- unsigned char sequence_number;
+private:
+ unsigned char sequence_number{};
+ // Path for file access error handling (ERR_FILE_ACCESS)
std::string path;
Fl_PNG_Image *stored_img_pointer;
+public:
Puzzle(int x, int y)
: Fl_Button(x, y, puzzle_size, puzzle_size),
- stored_img_pointer(nullptr) {
- }
+ stored_img_pointer(nullptr)
+ {
+ }
~Puzzle() { delete stored_img_pointer; }
+ friend class GameParams;
+ friend class PuzzleGame;
+ friend class ASearch;
};
class GameParams {
@@ -43,9 +49,9 @@ private:
coordinates empty_box;
std::vector<std::unique_ptr<Puzzle>> puzzles;
Fl_Window *win;
- /*
- * selecting the current directory where the user image is stored
- */
+ // True while A* is solving the puzzle; blocks new game and solving again
+ bool is_a_star_active = false;
+ // selecting the current directory where the user image is stored
std::string cur_directory;
GameParams(Fl_Window *a_win = nullptr)
@@ -53,14 +59,17 @@ private:
{}
void CalculateStandardPuzzlePos();
void ResetFreePuzzles();
+ void ResetAStarActive() { is_a_star_active = false; }
+ void SetAStarActive() { is_a_star_active = true; }
void NextUntestedPuzzles();
bool IsSolvability();
void CreateNewPuzzles();
void SelectRandomPicture();
Fl_PNG_Image *LoadPictureParts(std::unique_ptr<Puzzle>& tmp_puzzle);
-public:
void SetXYEmptyBox(int x, int y) { empty_box.x = x; empty_box. y = y; }
coordinates GetXYEmptyBox() { return empty_box; }
+public:
+ bool GetAStarActive() { return is_a_star_active; }
static GameParams *SetUpParams(Fl_Window *win) {
if(instance)
return instance;