#ifndef PUZZLE_HPP_SENTRY #define PUZZLE_HPP_SENTRY #include #include #include #include #include #include enum { puzzle_pieces = 9, 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; bool operator==(const coordinates& v) const { return this->x == v.x && this->y == v.y; } }; private: static GameParams *instance; coordinates standard_puzzle_coordinates[puzzle_pieces]; char free_puzzles[puzzle_pieces]; coordinates empty_box; std::vector> puzzles; Fl_Window *win; std::string cur_directory; GameParams(Fl_Window *a_win = nullptr) : win(a_win) {} void CalculateStandardPuzzlePos(); void ResetFreePuzzles(); void NextUntestedPuzzles(); bool IsSolvability(); void CreateNewPuzzles(); void SelectRandomPicture(); friend class PuzzleGame; friend class ASearch; friend void press_button_callback(Fl_Widget*, void*); friend void solve_problem_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) { if(instance) return instance; GameParams *gi = new GameParams(win); gi->CalculateStandardPuzzlePos(); return gi; } }; #endif