Puzzle15 Sample

This sample is located in \Samples\afc11\Puzzle15.

Description
Using the Sample
Key Project Files
Technologies Demonstrated

Description

The Puzzle15 sample is a game that displays a panel of scrambled numbers to be placed in their correct order. The sample shows how to use property sheets, marquees, and other UI controls. When the applet first loads, a property dialog box appears that contains tab pages for setting game and navigation options.

The Options property page contains two controls:

The Navigation property page determines how pressing the arrow keys affects the puzzle.

The main game panel contains the following components:

Using the Sample

You can also run the sample as an application with the following command:

wjview Puzzle15

To use the sample

The object of the game is to unscramble the numbers (putting them in their correct order), using the minimum number of moves possible. To play the game, do the following:

  1. When the applet starts, a dialog box appears for selecting game setup options. On the Options tab, enter (or use the arrows to select) the amount of scrambling you want. If you don't want the computer to find an optimum solution, clear this option.

  2. Click the Navigation tab, select the navigation option you want to use with the arrow keys, and then click OK. The navigation options are as follows:

    Note   You can also use the mouse to select and move buttons.

  3. Rearrange the numbers by moving the buttons or blank space using the arrow keys or mouse clicks. Press CTRL+Z to undo a move, if necessary. The Statistics area reports your progress. The marquee displays a message if you exceed the optimal solution.

  4. The Game menu, displayed by clicking the Game button at the top of the main panel, contains the following options:

Key Project Files

Pz15Data.java

This class implements Pz15Consts. It scrambles the game pieces in accordance with the value set in the Options property page, and accepts and evaluates the user's move.

Pz15GamePanel.java

This class extends UIGroup and implements Pz15Consts. It updates the game board's internal representation as moves are made.

Pz15InfoPanel.java

This class extends UIPanel and implements Pz15Consts. It tracks and displays game statistics.

Pz15Solver.java

This class extends Pz15Data and implements Runnable and Pz15Consts. It calculates the optimal solution given the starting position.

Pz15PropGame.java

This class extends UIPropertyPage and implements Pz15Consts and IFxTextConstants. It defines the Game property sheet.

Pz15Options.java

This class extends UIPropertyDialog and implements Pz15Consts. It defines the Options property page.

Pz15PropNav.java

This class extends UIPropertyPage and implements Pz15Consts. It defines the Navigation property page.

Technologies Demonstrated

AFC

© 1999 Microsoft Corporation. All rights reserved. Terms of use.