From e64c2a9d94bb6e21ac24d7e1ff5915a29bbd67bf Mon Sep 17 00:00:00 2001 From: scratko Date: Sat, 9 Nov 2024 20:00:19 +0300 Subject: Moving slides Changed to 8 puzzles Added reaction to clicking a puzzle Puzzles are moved to vector --- puzzle.hpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'puzzle.hpp') diff --git a/puzzle.hpp b/puzzle.hpp index 6ceb6e1..5b2b2ab 100644 --- a/puzzle.hpp +++ b/puzzle.hpp @@ -4,40 +4,46 @@ #include #include #include +#include +#include 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> 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; } }; -- cgit v1.2.3