Sliding Puzzle Game (C++)
Welcome to the Sliding Puzzle Game, a console-based logic game that challenges your brain and reflexes. Slide the tiles until every tile is in numerical order, with the empty space at the bottom-right corner.
Features
Customizable Grid Size
Choose board dimensions between 3x3 and 10x10.
Color-coded Tiles
Green: correct, Red: incorrect, Yellow: empty space.
Randomized Scrambling
Ensures the board starts in a valid, solvable state.
Intuitive Controls
Use W, A, S, D keys to slide tiles.
Win Detection
Automatically detects when the puzzle is solved.
Clean Memory Handling
Dynamically allocated memory is released properly in the destructor.
Getting Started
Prerequisites
- Windows OS (required for <Windows.h> and <conio.h>)
- C++ Compiler (MSVC, MinGW, or any supporting C++11)
Build and Run
git clone https://github.com/yourusername/sliding-puzzle.git
cd sliding-puzzle
g++ main.cpp SlidingPuzzle.cpp -o SlidingPuzzle.exe
SlidingPuzzle.exeGame Instructions
Move tiles using the following keys:
W → UP
A → LEFT
S → DOWN
D → RIGHT
Q → Quit the gameTiles slide into the empty space (*) if the move is valid. The board is solved when all numbers are in ascending order, ending with the empty space.
Project Structure
sliding-puzzle/
├── main.cpp # Main program with user interaction and game loop
├── SlidingPuzzle.h # Class declaration
├── SlidingPuzzle.cpp# Class implementation
├── README.md # Project documentation
├── LICENSE # License information
└── .gitignore # Ignored files and foldersAuthor
Saumya Brahmbhatt
Computer Science Major
Acknowledgments
Special thanks to Harford Community College for inspiring this academic project.
Built as a demonstration of imperative programming, arrays, pointers, and dynamic memory in C++.