diff options
Diffstat (limited to 'puzzle.hpp')
-rw-r--r-- | puzzle.hpp | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -3,6 +3,7 @@ #include <FL/Enumerations.H> #include <FL/Fl_Button.H> +#include <FL/Fl_Window.H> #include <string> #include <vector> #include <memory> @@ -14,12 +15,12 @@ enum { spacing = 5 }; -class Puzzle : Fl_Button{ +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) {} - friend class GameParams; }; class GameParams { @@ -32,20 +33,24 @@ private: 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) {} - GameParams() {} void CalculateStandardPuzzlePos(); void ResetFreePuzzles(); void NextUntestedPuzzles(); bool IsSolvability(); void CreateNewPuzzles(); + friend class PuzzleGame; + friend void press_button_callback(Fl_Widget*, void*); public: - void NewGame(); void SetXYEmptyBox(int x, int y) { empty_box.x = x; empty_box. y = y; } coordinates GetXYEmptyBox() { return empty_box; } - static GameParams *SetUpParams() { - GameParams *gi = new GameParams; + static GameParams *SetUpParams(Fl_Window *win) { + GameParams *gi = new GameParams(win); gi->CalculateStandardPuzzlePos(); + gi->SetXYEmptyBox(215, 215); return gi; } }; |