back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/puzzle.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'puzzle.hpp')
-rw-r--r--puzzle.hpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/puzzle.hpp b/puzzle.hpp
index 6ceb6e1..5b2b2ab 100644
--- a/puzzle.hpp
+++ b/puzzle.hpp
@@ -4,40 +4,46 @@
#include <FL/Enumerations.H>
#include <FL/Fl_Button.H>
#include <string>
+#include <vector>
+#include <memory>
enum {
- puzzle_pieces = 15,
- puzzles_per_side = 4,
- puzzle_size = 75,
+ puzzle_pieces = 8,
+ puzzles_per_side = 3,
+ puzzle_size = 100,
spacing = 5
};
class Puzzle : Fl_Button{
- unsigned int sequence_number;
+ unsigned char sequence_number;
std::string path;
Puzzle(int x, int y)
- : Fl_Button(x, y, puzzle_size, puzzle_size),
- sequence_number(0) {}
+ : Fl_Button(x, y, puzzle_size, puzzle_size) {}
friend class GameParams;
};
class GameParams {
+public:
struct coordinates {
int x, y;
};
- coordinates puzzle_coordinates[puzzle_pieces];
+private:
+ coordinates standard_puzzle_coordinates[puzzle_pieces];
char free_puzzles[puzzle_pieces];
- Puzzle *puzzles[puzzle_pieces];
- GameParams() : puzzles{nullptr} {}
+ coordinates empty_box;
+ std::vector<std::unique_ptr<Puzzle>> puzzles;
+
+ GameParams() {}
+ void CalculateStandardPuzzlePos();
void ResetFreePuzzles();
- void CalculatePuzzlePos();
void CreateNewPuzzles();
public:
void NewGame();
-
- static GameParams *StartParams() {
+ 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;
- gi->CalculatePuzzlePos();
+ gi->CalculateStandardPuzzlePos();
return gi;
}
};