diff options
author | scratko <m@scratko.xyz> | 2024-10-25 00:40:58 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2024-10-25 00:50:53 +0300 |
commit | 365c27f05d5739213d3a98aa41dcc7f1cb0a6c60 (patch) | |
tree | 96fd9f7a1a808b6ab96e310037b9db376921d2f1 /puzzle.hpp | |
download | picture-puzzle-365c27f05d5739213d3a98aa41dcc7f1cb0a6c60.tar.gz picture-puzzle-365c27f05d5739213d3a98aa41dcc7f1cb0a6c60.tar.bz2 picture-puzzle-365c27f05d5739213d3a98aa41dcc7f1cb0a6c60.zip |
Initial commit
Creating widgets with a split image
Diffstat (limited to 'puzzle.hpp')
-rw-r--r-- | puzzle.hpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/puzzle.hpp b/puzzle.hpp new file mode 100644 index 0000000..6ceb6e1 --- /dev/null +++ b/puzzle.hpp @@ -0,0 +1,45 @@ +#ifndef PUZZLE_HPP_SENTRY +#define PUZZLE_HPP_SENTRY + +#include <FL/Enumerations.H> +#include <FL/Fl_Button.H> +#include <string> + +enum { + puzzle_pieces = 15, + puzzles_per_side = 4, + puzzle_size = 75, + spacing = 5 +}; + +class Puzzle : Fl_Button{ + unsigned int sequence_number; + std::string path; + Puzzle(int x, int y) + : Fl_Button(x, y, puzzle_size, puzzle_size), + sequence_number(0) {} + friend class GameParams; +}; + +class GameParams { + struct coordinates { + int x, y; + }; + coordinates puzzle_coordinates[puzzle_pieces]; + char free_puzzles[puzzle_pieces]; + Puzzle *puzzles[puzzle_pieces]; + GameParams() : puzzles{nullptr} {} + void ResetFreePuzzles(); + void CalculatePuzzlePos(); + void CreateNewPuzzles(); +public: + void NewGame(); + + static GameParams *StartParams() { + GameParams *gi = new GameParams; + gi->CalculatePuzzlePos(); + return gi; + } +}; + +#endif |