Why the World Needs a New Picture Puzzle
The art of solving picture puzzles is a sadly missed part of our modern culture, and the current penury of pass-times which sharpen the mind is the focal point which incites well-meaning members of the World's Independent Masters of Picture Puzzles (WIMPPs International) to charter new grounds in their far-reaching quest to create better picture puzzles with which to delight us all.
Picture Puzzles Can't Cure Cancer
... but they can keep you from thinking too hard about getting cancer, and isn't that what really matters?
It's Just a Game
I think everybody has seen a sliding picture puzzle at some point in their lives. The only difference between this one and the ones your folks gave you on long road-trips is that this one is on your computer or whatever portable console you happen to be using. To move tiles around, just click the tile you want to move, and if it is next to the 'hole' tile, then it'll move to the hole-spot.
An added fun bit here is that you get to hear a soothing harp-like tinkle to the ear whenever a piece is placed in the right spot, better than hearing your kid-sister's constant kibitzing about which tile goes where, right! You can toggle-view the 'solution', or completed puzzle image, but I think the part of this puzzle you'll like most is that you can finally make a sliding-picture puzzle out of old Linda Carter 'Wonder Woman' images you can download off the internet. Come on, admit it, this is what you've been waiting for!
How Does It Work
The most important parts of this program, what makes it all tick, are these two arrays:
Let's see if I can sum this up simply:
- There's a two-dimensional array of bitmaps which holds the images of all the tiles.
- Then there's a two-dimensional array of Cartesian (x,y) which is of the same size, and this array tells the program which tile is located where. Each element in this array is initialized when a new puzzle is created, and the puzzle is solved when
udrII for short):
udrII[i,j].x = i
udrII[i,j].j = j
for all i,j.
And when a tile is moved, the values of this array are swapped between the moving-tile's initial position and the moving-tile's final position. It is not that complicated, it might just seem so right now, because it's 3am and I didn't take my Flintstones vitamins today, but if you look at the code and think about it, it's really not much.
And that's the gist of it.
The puzzle is displayed on a single picture box by collaging all the
bmp[,] images in the order that they are pointed to in the
udrII[,] array. This picturebox has two event handlers:
mousemove(), which sets a global Cartesian to the tile index of the tile under the mouse cursor, and a
mouseclick() event handler which first tests if the tile clicked can be moved and then makes the move if it can. When tiles are moved, another global variable keeps track of where the 'hole' tile is, for quicker tests and future reference, and the puzzle is tested to see if it has been solved.
You might have noticed the class
MessageBox (A Versatile MessageBox); it's a handy class, and though it's such a simple few lines of code, it really does the job where other message boxes are too formal with their 'Yes', 'No', and 'OK' buttons when the buttons you really need are 'medium' or 'large'.
Point of Concern
It is a puzzling circumstance, but due to current squabbling among the upper-echelon of the WIMPPS International, the world's leading riddle-league is not currently accepting membership applications.
- 8th November, 2009: Initial post
- 15th November, 2009: Updated source code