diff options
author | scratko <m@scratko.xyz> | 2025-07-25 17:04:21 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2025-07-25 17:46:22 +0300 |
commit | 90bd5ca05bea4dbeaaeff5cbe13b5671da420c82 (patch) | |
tree | 05757ed9b9ea0c007f4b4e86cfd8402fea4c6a5d /puzzle.hpp | |
parent | ac9a06b04144023e87d1a504cfe5598e7cf3d7b4 (diff) | |
download | picture-puzzle-90bd5ca05bea4dbeaaeff5cbe13b5671da420c82.tar.gz picture-puzzle-90bd5ca05bea4dbeaaeff5cbe13b5671da420c82.tar.bz2 picture-puzzle-90bd5ca05bea4dbeaaeff5cbe13b5671da420c82.zip |
Added const qualifiers is_next_to_empty_box() became visible to other files().
The size of the main window has been changed.
Checking whether the A* algorithm has been launched before starting a new game
or the same A* algorithm.
Fixed indentation in lambda expressions.
The initial node is added to open_queue without additional creation of dynamic
memory (the address of the object field is taken).
Fixed PQ_cont.erase().
IsNearEmptyBox was removed().
EqualNode moved to the Node class.
Diffstat (limited to 'puzzle.hpp')
-rw-r--r-- | puzzle.hpp | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -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; |