|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Canvas
nanomunchers.ui.NanoSimulation
Arguably the largest piece of the Nanomunchers game is the simulation that shows the state of the game at each frame. This Simulation class merely plays a set of frames. The Simulator class is the one that builds the frames themselves.
Nested Class Summary |
Nested classes inherited from class java.awt.Canvas |
java.awt.Canvas.AccessibleAWTCanvas |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
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 | |
NanoSimulation(heurgame.ui.PlayerColors pc,
heurgame.event.PlayerBroadcaster playerSpeaker)
Sets up a new simulation |
Method Summary | |
boolean |
decreaseSpeed()
Slows down the simulation either by adding frames (if any were skipped) or by lengthening the delay between frames |
boolean |
increaseSpeed()
Either shortens the delay or skips frames. |
static void |
main(java.lang.String[] args)
Debugging method |
void |
nextFrame()
Finishes the current frame |
void |
nextMove(java.lang.Integer nanoId,
Node place,
int munched,
boolean alive,
boolean naturaldeath)
Constructs a piece of a frame |
void |
paint(java.awt.Graphics g)
Only paints if the simulation is not running. |
void |
play()
Reads through the frames and plays them at whatever the current speed is. |
java.lang.Integer |
register(heurgame.PlayerToken owner,
NanoBot nb)
|
void |
setFrameListener(FrameListener frame)
|
void |
setSimulationSpeed(double s)
Changes the speed of the simulation without skipping frames. |
void |
setup(Graph graph)
Initializes the simulation |
void |
update(java.awt.Graphics g)
If the graph is not null draws the simulation. |
Methods inherited from class java.awt.Canvas |
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public NanoSimulation(heurgame.ui.PlayerColors pc, heurgame.event.PlayerBroadcaster playerSpeaker)
pc
- Colors for each player.playerSpeaker
- to notify any listeners of score changes.Method Detail |
public void setFrameListener(FrameListener frame)
frame
- to be notified when frames are either being added or played.public void setup(Graph graph)
graph
- to be displayedpublic java.lang.Integer register(heurgame.PlayerToken owner, NanoBot nb)
public void nextMove(java.lang.Integer nanoId, Node place, int munched, boolean alive, boolean naturaldeath)
nanoId
- object ref of a registered botplace
- where the bot ismunched
- how many nodes has it munchedalive
- whether the bot is alivenaturaldeath
- whether or not the bot exhausted its food supplypublic void nextFrame()
public void setSimulationSpeed(double s)
s
- Larger numbers yeild a SLOWER speed.public boolean decreaseSpeed()
public boolean increaseSpeed()
public void play()
public void paint(java.awt.Graphics g)
Component.paint(java.awt.Graphics)
public void update(java.awt.Graphics g)
Component.update(java.awt.Graphics)
public static void main(java.lang.String[] args)
args
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |