JavaView® v2.00.008

vgp.game.mines
Class PnMinesweeper

java.lang.Object
  |
  +--jv.object.PsObject
        |
        +--jv.project.PjProject
              |
              +--jvx.geom.PnCellOperator
                    |
                    +--vgp.game.mines.PnMinesweeper
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, java.awt.event.KeyListener, PsTimeListenerIf, PsUpdateIf, PvPickListenerIf, java.lang.Runnable, java.io.Serializable

public class PnMinesweeper
extends PnCellOperator
implements java.awt.event.KeyListener

Minesweeper game on arbitrary polyhedral surfaces.

Version:
16.05.00, 1.00 created (ur)
Author:
Ulrich Reitebuch
See Also:
Serialized Form

Field Summary
protected  boolean m_bExploding
          Flag, if the geometry is just exploding.
protected  boolean m_bFirstPick
          Flag, if allready a face was picked.
protected  boolean[] m_bMines
          Positions of mines.
protected  boolean m_bShift
          Flag, if shift-key is pressed.
protected  long m_endTime
          Absolute time of last face geting opened.
protected  PnExplodeElementSet m_expl
          Explosion.
protected  double m_explGravity
          Acceleration towards earth-mid-point for explosion.
protected  PvDisplay m_explodeDisplay
          Display, which shows the geometry.
protected  double m_explRotationSpeed
          Maximal rotation speed of faces in explosion.
protected  double m_explSpeed
          Maximal starting speed of faces in explosion.
protected  PiVector m_minedNeighbours
          Number of mined neighbour faces.
protected  int m_numMines
          Number of mines on the surface.
protected  int m_numOpen
          Number of opened faces.
protected  java.util.Random m_random
          Random function to get mine positions.
protected  long m_startTime
          Absolute time of first pick.
protected  PnMinesweeper_Dialog m_winDialog
          Dialog window for winning.
 
Fields inherited from class jvx.geom.PnCellOperator
CORONA, influence, LIFE, m_bHasElementColors, m_bMarkGlider, m_bShowTaggedElements, m_bUpdateSender, m_bUseGlobalElementColor, m_color, m_currLoop, m_dialog, m_geom, m_geomElement, m_geomNeighbour, m_infCell, m_markI, m_numLoops, m_numStates, m_originalColors, m_outputType, m_panel, m_sleepTime, m_thread, m_vertexStar, MAJORITY, NEIGHBOUR, rule, SET_COLOR, SET_ELEMENT_TAG
 
Fields inherited from class jv.project.PjProject
m_anim, m_bAutoFit, m_display, m_displayList, m_geometry, m_parm, m_rootGeometry
 
Fields inherited from class jv.object.PsObject
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, m_infoPanel, m_name, m_panelList, m_parent, m_tag, m_updateList, NUM_TAGS
 
Constructor Summary
PnMinesweeper(PgElementSet anElementSet)
          Constructor
 
Method Summary
protected  void explode()
          Let the elementSet explode, if a mined element is picked.
 void init()
          Initialization
 void keyPressed(java.awt.event.KeyEvent e)
          Store, if shift key is pressed.
 void keyReleased(java.awt.event.KeyEvent e)
          Store, if shift key is pressed.
 void keyTyped(java.awt.event.KeyEvent e)
          Just to fullfill KeyListener interface.
protected  void openNeighbours(int elementInd)
          Mark all neighbouring cells, which are not marked to be a mine.
 void pickInitial(PvPickEvent pos)
          Pick elementsto mark or unmark to be a mined element or to be a not mined element.
 void run()
          Just to disable PnCellOperator.run().
 void setExplodeDisplay(PvDisplay aDisplay)
          Store Display.
 void setMines(int noMine)
          Get random positions for mines.
 void start()
          Just to disable PnCellOperator.start().
 void stop()
          Just to disable PnCellOperator.stop().
 boolean update(java.lang.Object event)
          Update the class whenever a child has changed.
 
Methods inherited from class jvx.geom.PnCellOperator
cellOperator, clear, compute, evaluate, getColor, getDialog, getNumStates, getState, makeCoronaInfluence, makeInfluence, makeNeighbourInfluence, markElement, markElement, markGlider, releasePick, requestPick, restoreColors, ruleOfLife, ruleOfMajority, setColor, setColors, setCurrLoop, setElementTags, setInfluence, setNumLoops, setNumStates, setOutputType, setRule
 
Methods inherited from class jv.project.PjProject
addDisplay, addGeometry, addGeometry, dispose, dragDisplay, dragInitial, dragVertex, fitDisplays, getAnimation, getDisplay, getDisplays, getGeometry, getGeometry, getNumGeometries, getParameter, getViewer, hasAnimation, hasDisplay, isEnabledAutoFit, markVertices, pickDisplay, pickVertex, removeDisplay, removeGeometries, removeGeometry, selectDisplay, selectGeometry, setAnimation, setDisplay, setEnabledAutoFit, setParameter, setTime, setViewer, unmarkVertices
 
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, removeInspector, removeUpdateListener, setName, setParent, setTag, toString, updatePanels
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jv.anim.PsTimeListenerIf
getName
 
Methods inherited from interface jv.project.PvPickListenerIf
getName
 
Methods inherited from interface jv.object.PsUpdateIf
getFather, getName, setParent
 

Field Detail

m_numMines

protected int m_numMines
Number of mines on the surface.

m_numOpen

protected int m_numOpen
Number of opened faces.

m_minedNeighbours

protected PiVector m_minedNeighbours
Number of mined neighbour faces.

m_bShift

protected boolean m_bShift
Flag, if shift-key is pressed.

m_bMines

protected boolean[] m_bMines
Positions of mines.

m_random

protected java.util.Random m_random
Random function to get mine positions.

m_bFirstPick

protected boolean m_bFirstPick
Flag, if allready a face was picked.

m_expl

protected PnExplodeElementSet m_expl
Explosion.

m_explSpeed

protected double m_explSpeed
Maximal starting speed of faces in explosion.

m_explGravity

protected double m_explGravity
Acceleration towards earth-mid-point for explosion.

m_explRotationSpeed

protected double m_explRotationSpeed
Maximal rotation speed of faces in explosion.

m_explodeDisplay

protected PvDisplay m_explodeDisplay
Display, which shows the geometry.

m_bExploding

protected boolean m_bExploding
Flag, if the geometry is just exploding.

m_startTime

protected long m_startTime
Absolute time of first pick.

m_endTime

protected long m_endTime
Absolute time of last face geting opened.

m_winDialog

protected PnMinesweeper_Dialog m_winDialog
Dialog window for winning.
Constructor Detail

PnMinesweeper

public PnMinesweeper(PgElementSet anElementSet)
Constructor
Method Detail

init

public void init()
Initialization
Overrides:
init in class PnCellOperator

setExplodeDisplay

public void setExplodeDisplay(PvDisplay aDisplay)
Store Display.

update

public boolean update(java.lang.Object event)
Update the class whenever a child has changed. Method is usually invoked from the children.
Overrides:
update in class PnCellOperator
Following copied from interface: jv.object.PsUpdateIf
Parameters:
event - carries a lot of information
Returns:
true if event has been handled, otherwise false
See Also:
PsObject, PsUpdateIf.getFather(), PsUpdateIf.setParent(PsUpdateIf)

setMines

public void setMines(int noMine)
Get random positions for mines.

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Store, if shift key is pressed.
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Store, if shift key is pressed.
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Just to fullfill KeyListener interface.
Specified by:
keyTyped in interface java.awt.event.KeyListener

pickInitial

public void pickInitial(PvPickEvent pos)
Pick elementsto mark or unmark to be a mined element or to be a not mined element.
Overrides:
pickInitial in class PnCellOperator
Following copied from class: jv.project.PjProject
Parameters:
pos - Pick event issued by the display
See Also:
PvPickListenerIf

openNeighbours

protected void openNeighbours(int elementInd)
Mark all neighbouring cells, which are not marked to be a mine.

explode

protected void explode()
Let the elementSet explode, if a mined element is picked.

start

public void start()
Just to disable PnCellOperator.start().
Overrides:
start in class PnCellOperator
Following copied from class: jv.project.PjProject
See Also:
PvViewerIf.start(), #isEnabledAutoFit(boolean)

stop

public void stop()
Just to disable PnCellOperator.stop().
Overrides:
stop in class PnCellOperator
Following copied from class: jv.project.PjProject
See Also:
PvViewerIf.stop()

run

public void run()
Just to disable PnCellOperator.run().
Overrides:
run in class PnCellOperator

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.