My First Pygame Game

After discovering pygame back in November, I thought I'd write a small simple game to see how easy it was to use. I finished the first version of it over the Christmas break.

Just like for Zillions of Games, I decided to implement a variant of Sam Loyd's 15 puzzle. I used the Duncan and Dusti Christmas picture from 2 years ago, and turned it into a 3x3 sliding puzzle.

If you have Pygame (and its dependancies) installed on your computer, then you can downloaded a compressed tarball of all the files you need.

Once you've unpacked the gzipped tarball, change directories to the slidepuzzle directory, and type:

% ./slidepuzzle.py

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.

If you just want to look at the Python source code, I made the slidepuzzle.py file available too.

Note that this version uses some nice sound files, shamelessly copied from the public domain Magicor game.

The pygame API is nice and clean. Admittedly I haven't explored all there is to offer yet, but it wasn't too hard to work out what I needed in order to get this simple game working, especially after reading the tutorials first.

The next changes will be to allow you to specify any image file on the command line and the size of the grid (3x3, 4x4 or 5x5). I'll also allow you to select which square is the one that is initially removed. If I get enthused, I might further adjust it so that you don't need to use any command line options, and all these things are settable via a normal Preferences type screen.

[]

[]

[]

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