diff options
author | scratko <m@scratko.xyz> | 2024-11-09 20:00:19 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2024-11-09 20:12:48 +0300 |
commit | e64c2a9d94bb6e21ac24d7e1ff5915a29bbd67bf (patch) | |
tree | 5d42ff77afaeb101ff260ddf06b733cf0ef6fa61 /puzzle.hpp | |
parent | 365c27f05d5739213d3a98aa41dcc7f1cb0a6c60 (diff) | |
download | picture-puzzle-e64c2a9d94bb6e21ac24d7e1ff5915a29bbd67bf.tar.gz picture-puzzle-e64c2a9d94bb6e21ac24d7e1ff5915a29bbd67bf.tar.bz2 picture-puzzle-e64c2a9d94bb6e21ac24d7e1ff5915a29bbd67bf.zip |
Moving slides
Changed to 8 puzzles
Added reaction to clicking a puzzle
Puzzles are moved to vector
Diffstat (limited to 'puzzle.hpp')
-rw-r--r-- | puzzle.hpp | 32 |
1 files changed, 19 insertions, 13 deletions
@@ -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; } }; |