Game Setup

The MIDlet starts by displaying a list of options for the user contained in MenuList. At the beginning, the only options are to start a new game and show the Graphics3D properties. When the user starts a new game, a Maze object is created, the maze is generated, and the scene graph is built in the MazeCanvas' init method. Past this the start method creates a new Thread that will drive the drawing loop. Meanwhile, a timer is being updated comparing the start of the game's time with the current time, to keep track of how long the game has been played.

The stop method halts the thread and freezes the timer. This is done, for instance, when the main menu is displayed again or the application is externally paused. The keyPressed method listens for key events, and in case they don't correspond to standard values the MenuList is presented. It is possible to switch from the normal view to the top view, and vice versa. It is also possible to halt the current game and start a new one.

The game is finished when the player reaches the end mark. Each time the player moves, his/her position is tested to see if it is close enough to the end of the maze. When it is, the game ends and the timer is stopped.