pacman.engine
Class World

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by pacman.engine.World
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class World
extends java.awt.Frame

Initializes and handles the display of the scene.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  javax.media.j3d.Canvas3D c3d
          Holds the display to be rendered to the screen
private  javax.media.j3d.BranchGroup content
          Contains the scene objects (walls, ghosts, etc.)
private  int direction
          Direction the player is facing; initially north
static java.util.Set food
          Collection of the food objects
static java.util.Set fruit
          Collection of the fruit objects
static java.util.Set ghosts
          Collection of the ghosts
static int level
          Current level
private  int[] mapSize
          The dimensions of the Radar
private  MenuPanel menu
          Reference to the main menu
private  Physics physics
          Physics processor
static java.awt.Rectangle pos
          Position and bounding rectangle of the player
private  Radar radar
          A 2D top-down view of the scene
static int score
          Current score
private  com.sun.j3d.utils.universe.SimpleUniverse su
          Universe containing the scene
static java.util.Map tgroups
          Collection of the TransformGroups
private  javax.media.j3d.TransformGroup transform
          Contains the transformations that position the scene objects in their appropriate places
static java.util.Set walls
          Collection of the wall objects
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
World(MenuPanel m)
          Constructs a World with a reference to the parent MenuPanel and calls the initialize method.
 
Method Summary
private  void createRadar()
          Initializes the Radar class.
private  void createScene()
          Reads in the level's map file and parses it into scene objects, wrapping each object in its own TransformGroup and adding that TransformGroup to the scene's primary TransformGroup, which is then added to the scene's BranchGroup.
 void eat(java.lang.Object temp)
          Removes a Food or Fruit object from the scene.
 java.util.Set getFood()
           
 java.util.Set getFruit()
           
 java.util.Set getGhosts()
           
 java.awt.Rectangle getPos()
           
 javax.media.j3d.TransformGroup getView()
          Returns the scene's ViewPlatformTransform; used by the Physics class turnLeft, turnRight, and move methods to animate the scene based on user input.
 java.util.Set getWalls()
           
 void initFullScreen()
          Puts the application into FSEM.
 void initialize()
          Initializes the World's variables, calls the createScene method, sets up the scene, and sends the application into fullscreen exclusive mode (FSEM).
 void startThreads()
          Starts all of the threads
 void stop()
          Stops the program threads.
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

level

public static int level
Current level


score

public static int score
Current score


menu

private MenuPanel menu
Reference to the main menu


physics

private Physics physics
Physics processor


su

private com.sun.j3d.utils.universe.SimpleUniverse su
Universe containing the scene


c3d

private javax.media.j3d.Canvas3D c3d
Holds the display to be rendered to the screen


content

private javax.media.j3d.BranchGroup content
Contains the scene objects (walls, ghosts, etc.)


transform

private javax.media.j3d.TransformGroup transform
Contains the transformations that position the scene objects in their appropriate places


radar

private Radar radar
A 2D top-down view of the scene


mapSize

private int[] mapSize
The dimensions of the Radar


direction

private int direction
Direction the player is facing; initially north


pos

public static java.awt.Rectangle pos
Position and bounding rectangle of the player


walls

public static java.util.Set walls
Collection of the wall objects


food

public static java.util.Set food
Collection of the food objects


fruit

public static java.util.Set fruit
Collection of the fruit objects


ghosts

public static java.util.Set ghosts
Collection of the ghosts


tgroups

public static java.util.Map tgroups
Collection of the TransformGroups

Constructor Detail

World

public World(MenuPanel m)
Constructs a World with a reference to the parent MenuPanel and calls the initialize method.

Method Detail

initialize

public void initialize()
Initializes the World's variables, calls the createScene method, sets up the scene, and sends the application into fullscreen exclusive mode (FSEM).


initFullScreen

public void initFullScreen()
Puts the application into FSEM.


startThreads

public void startThreads()
Starts all of the threads


getView

public javax.media.j3d.TransformGroup getView()
Returns the scene's ViewPlatformTransform; used by the Physics class turnLeft, turnRight, and move methods to animate the scene based on user input.


getFood

public java.util.Set getFood()

getFruit

public java.util.Set getFruit()

getWalls

public java.util.Set getWalls()

getGhosts

public java.util.Set getGhosts()

getPos

public java.awt.Rectangle getPos()

stop

public void stop()
Stops the program threads.


createScene

private void createScene()
                  throws java.lang.Exception
Reads in the level's map file and parses it into scene objects, wrapping each object in its own TransformGroup and adding that TransformGroup to the scene's primary TransformGroup, which is then added to the scene's BranchGroup.

Throws:
java.lang.Exception

createRadar

private void createRadar()
Initializes the Radar class.


eat

public void eat(java.lang.Object temp)
Removes a Food or Fruit object from the scene.