Pygame Slidepuzzle - Update 9th February 2007

Friday is hacking day.

A followup to a previous post.

I've created a new compressed tarball of the Pygame Slidepuzzle

I've made the following changes:

Added in support for various command line options and adjusted the code to handle them:
  • -?, --help - print out the usage message and exit.
  • -i, --image - path of the image file to use.
  • -s, --size - number of rows and columns to use. Range 2-6.
  • -m, --missing - square that should be empty Numbered from 1.

Assuming you've got pygame (and its dependencies) installed -- and it's just a few clicks away via the Synaptic Package Manager on Ubuntu -- you can then download the Slidepuzzle compressed tarball, unpack it, and then turn your favorite image into a nice sliding puzzle.

For example, I found a nice digital copy of the Mona Lisa on the web and resized it to half its original size, and saved it in the directory where I unpacked slidepuzzle-0.2.

I can now turn it into a 4x4 sliding puzzle with the bottom right corner initially blank with:

  % cd /path/to/slidepuzzle-0.2
  % python slidepuzzle.py --image mona_lisa.jpg --size 4 --missing 16

Type "s" to randomly shuffle the tiles, then use the arrow keys or the mouse to try to solve the puzzle. "q" or Esc will quit the game.

The next step is to try to adjust the code so that there are initial controls like "Play", "Options" and "Quit" and you don't have to set things via command line options. You know, like a real game. I'll probably be again stealing chunks of the public domain Magicor game to do this.

Another update (and probably fairly simple) would be to allow a different number of rows and columns. The "-s", "--size" command line option would change to "-r", "--rows" and "-c", "--columns" and the Python code tweaked accordingly.

But that's all for another day. Back to RealWork™

[]

[]

[]

Comments:

Post a Comment:
Comments are closed for this entry.
About

user12607856

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today