Use graphics.py.
It is a simple graphics library.
Click HERE
for more information.
(download, install, documentation, ...)
Project #1
Create an interactive puzzle in a graphics window.
It consists of cells containing numbers.
To win, the user must arrange
the number cells in a specific order.
- left to right, in numeric order, starting at the top left
cell
- top to bottom, in numeric order, starting at the top left
cell
- other
There is one blank cell. This cell can swap places
with an adjacent numbered cell.
Clicking on a numbered cell adjacent to (touching)
the blank cell will cause the cells to swap place.
(Touching top, bottom, left, and right. No diagonals.)
When the puzzle is complete a congratulations message is displayed.
The number of moves (swaps) is also displayed.
See the "Sample Puzzle Layout" below.
Design Thoughts
- Controls available to the user
- start the puzzle?
- restart/reset the puzzle?
- start a new puzzle?
- quit the puzzle?
- save the puzzle
- save the current state of the puzzle so the user can
stop in the middle and come back later?
- Number of cells and puzzle layout
- number of cells is fixed or
the user selects the number of cells?
- the layout is fixed or
the user selects a layout from several available?
- On puzzle start
- if multiple puzzle layouts are available,
one is randomly selected.
- a random cell is selected to be the blank cell.
- numbers are randomly distributed to the other cells.
- the puzzle and controls are displayed in a graphics window.
- The puzzle's cells do not need to be arranged
in a rectangle. How about a Diamond? A triangle? ...?
Sample Puzzle Layout