// 15-Puzzle
// Written by: Deepak Kumar
// November 2019
// Purpose: Program to play the 15-puzzle
// It displays a 15-puzzle
// Then the user can shuffle the tiles by pressing the 's' key.
// Using the arrow keys, the user can move the "blank" tile up, down, left, or right
Board puzzle; // The puzzle board
void setup() {
fullScreen();
puzzle = new Board(); // Create a fresh puzzle (solved)
puzzle.printBoard();
} // setup()
void draw() {
background(255);
puzzle.display();
} // draw()
void keyPressed() {
// User interaction
// pressing key 's' (code 83) shuffles the puzzle
if (keyCode == 83) puzzle.shuffle();
// pressing arrow keys will make the requested move: up, down, left, right
// Any key other than arrow is ignored
// also if a move cannot be made, it does nothing
puzzle.move(keyCode);
puzzle.display();
} // keyPressed()