diff options
author | scratko <m@scratko.xyz> | 2025-07-25 17:04:21 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2025-08-13 18:59:42 +0300 |
commit | 191a2d7cd56dde37d7f9fbdd1bcd2bb80ab4590d (patch) | |
tree | 404975753ee83eaf15f1575441477b209b65dd33 /README.md | |
parent | ac9a06b04144023e87d1a504cfe5598e7cf3d7b4 (diff) | |
download | picture-puzzle-191a2d7cd56dde37d7f9fbdd1bcd2bb80ab4590d.tar.gz picture-puzzle-191a2d7cd56dde37d7f9fbdd1bcd2bb80ab4590d.tar.bz2 picture-puzzle-191a2d7cd56dde37d7f9fbdd1bcd2bb80ab4590d.zip |
Added const qualifiers is_next_to_empty_box() became visible to other files().
The size of the main window has been changed.
Checking whether the A* algorithm has been launched before starting a new game
or the same A* algorithm.
Fixed indentation in lambda expressions.
The initial node is added to open_queue without additional creation of dynamic
memory (the address of the object field is taken).
Fixed PQ_cont.erase().
IsNearEmptyBox was removed().
EqualNode moved to the Node class.
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 82 |
1 files changed, 61 insertions, 21 deletions
@@ -1,35 +1,74 @@ -# Picture puzzle +# Picture Puzzle <img src="puzzle.png" /> -A desktop game similar to the standard widget in windows 7. The game is written -in C++ (including C++17 standard). FLTK was used as a graphics library. This -library is not as heavy as Qt, and allows to quickly create an application with -graphical widgets. +A desktop sliding puzzle game similar to the standard widget in Windows 7. +Written in modern **C++17** with **FLTK** for the graphical interface, it +provides a lightweight, cross-platform experience with fast compilation and +responsive UI. -The essence of the game should be clear: to collect the image in its original -form, moving one puzzle per move. +The goal is simple: rearrange the tiles to restore the original image, moving +one piece at a time. -The application has the following features: +--- -- *upload your image in any format and resolution. The program itself will - resize, cut into puzzles, create the appropriate directory and save them in - it.* +## Features -- *showing the complete solution of the puzzle using the optimization algorithm - A\*.* +### Image Handling +- Upload an image in **any format and resolution** — the program will: + - Resize it to fit the puzzle grid (`300x300`). + - Slice it into `3x3` tiles. + - Save tiles into a dedicated `resources/` subdirectory. +- Uses **stb_image**, **stb_image_resize**, and **stb_image_write** for image +loading, resizing, and saving. -- *the game is distributed in a single executable file by embedding the original - standard image (toucan image) in the executable file. The image data is stored - in an array in an object file (resources.o)* +### Built-in Embedded Image +- **Both Linux and Windows builds include a fully embedded image** (Toucan) directly inside the executable. +- The embedded image is stored in `resources.o` as a static **byte array**. +- A C-language **image converter** tool is included, which: + - Takes a PNG image. + - Generates a `resources.cpp` file containing the image bytes. +- This allows shipping the game as a **single executable** without requiring external image files. +- The embedded Toucan image serves as the default puzzle; users can still load their own images. -- *support for \*unix and Windows platforms* +### Puzzle Gameplay +- Standard 3×3 sliding puzzle with one empty tile. +- Random shuffling with **solvability check** to ensure the puzzle can be +completed. +- Option to load: + - Built-in embedded image. + - External images from `resources/` folder or user upload. + +### Automatic Puzzle Solver +- **A\*** search algorithm implementation. +- Uses **Manhattan distance** as the heuristic (`g(n) + W(n)`). +- Shows a **step-by-step animation** of the optimal solution. + +### Cross-Platform +- Works on **Linux** and **Windows**. +- On both platforms, distributed as a single executable with embedded resources. + +--- + +## Technologies Used +- **C++17 STL** — `std::unique_ptr`, `std::shared_ptr`, `priority_queue`, +`unordered_set`, `filesystem`, `algorithm`. +- **FLTK** — lightweight GUI library. +- **stb_image** / **stb_image_resize** / **stb_image_write** — image processing. +- **A\*** algorithm for optimal pathfinding. +- Custom hashing and equality comparison for puzzle states. +- **Custom C-based resource generator** for embedding binary image data into the executable. + +--- ## Building -For \*nix platform, you need to install FLTK library and then do the following: +### Linux -``` +Install FLTK development package: + +```bash +sudo apt install fltk1.3-dev git clone https://git.scratko.xyz/picture-puzzle cd picture-puzzle make @@ -38,6 +77,7 @@ make ## For Windows platform -The built executable file (under x86_64) is available at the link: <a -href="https://scratko.xyz/games/puzzle.exe" target="_blank">Download Windows +- Requires FLTK for Windows. +- Prebuilt x86_64 executable available here: +<a href="https://scratko.xyz/games/puzzle.exe" target="_blank">Download Windows version</a> |