back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/puzzle.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'puzzle.hpp')
-rw-r--r--puzzle.hpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/puzzle.hpp b/puzzle.hpp
index 5f51877..39a4752 100644
--- a/puzzle.hpp
+++ b/puzzle.hpp
@@ -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;
}
};