The User Interface


Class Diagrams for Maze3D

Figure 25-2 gives the class diagrams for the Maze3D application, including the class names and public methods.

Maze3D is the usual top-level JFrame but does a bit more than in previous examples since it builds the GUI interface for the three views of the game.

Figure 25-2. Class diagrams for Maze3D


WrapMaze3D is a JPanel that creates the 3D scene including the background, lighting, and the main camera viewpoint. It utilizes maze and floor subgraphs made by other objects, and it invokes a KeyBehavior object. The TexturedFloor and TexturedPlane classes are used to create the floor.

MazeManager reads in the maze plan (a text file) prepared outside of Maze3D and generates two representations: a Java 3D subgraph that is added to the scene and a Java 2D image of the maze passed to the BirdsEye object. BirdsEye draws a 2D overview of the maze and represents the user by moving and rotating an arrow over the top of the maze image. This bird's-eye view is displayed in the bottom righthand JPanel in the GUI. SecondViewPanel creates a second view branch subgraph showing the view behind the user's current position (the back facing camera). The subgraph is added to the main scene, and its Canvas3D object is linked to the top righthand JPanel in the GUI.

KeyBehavior converts key presses into moves and rotations of the two cameras, and it updates to the bird's-eye view.

The example code for this application can be found in the Maze3D/ directory.




Killer Game Programming in Java
Killer Game Programming in Java
ISBN: 0596007302
EAN: 2147483647
Year: 2006
Pages: 340

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net