jvx.cellular
Class PwSnake
- java.lang.Object
-
- jv.object.PsObject
-
- jvx.project.PjWorkshop
-
- jvx.cellular.PwSnake
-
- All Implemented Interfaces:
- java.awt.event.KeyListener, java.io.Serializable, java.lang.Cloneable, java.lang.Runnable, java.util.EventListener, PsUpdateIf, PjWorkshopIf
public class PwSnake extends PjWorkshop implements java.awt.event.KeyListener, java.lang.Runnable
Snake game on arbitrary polyhedral surfaces.- See Also:
- Serialized Form
- Author:
- Ulrich Reitebuch
- Version:
- 02.02.06, 1.10 revised (ur) Added a key buffer.
29.01.06, 1.00 created (ur)
-
-
Field Summary
-
Fields inherited from class jv.object.PsObject
HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS
-
Fields inherited from interface jv.project.PjWorkshopIf
MODE_BUG, MODE_STANDARD, MODE_VALIDATE
-
-
Constructor Summary
Constructors Constructor and Description PwSnake()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()Remove key listener from display, reset elementSet to state before starting the game, and destroy dialog window.voidinit()Resets all properties to default values.voidkeyPressed(java.awt.event.KeyEvent e)Store, if "Right" or "Left" key is pressed.voidkeyReleased(java.awt.event.KeyEvent e)Store, if "Right" or "Left" key is pressed.voidkeyTyped(java.awt.event.KeyEvent e)Just to fulfill KeyListener interface.voidpause()Pauses the game.voidreset()Reset workshop and geometry to original state.voidresume()Resumes a paused game.voidrun()Run the snake until it dies.voidsetDisplay(PvDisplayIf display)Store currently active display.voidsetGeometry(PgGeometry geom)Assign a geometry on which this workshop operates,voidstart()Start snake game in separate thread.voidstop()Stop snake game in separate thread.booleanupdate(java.lang.Object event)Update the class whenever a child has changed.-
Methods inherited from class jvx.project.PjWorkshop
cancel, getDisplay, getDisplays, getGeometry, getMode, getSavedGeometry, getViewer, isModal, isStandalone, ok, removeGeometry, setDisplays, setModal, setMode, setStandalone, setViewer
-
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, toString, updatePanels
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jv.object.PsUpdateIf
getFather, getName, setParent
-
-
-
-
Method Detail
-
init
public void init()
Resets all properties to default values.- Overrides:
initin classPjWorkshop
-
setGeometry
public void setGeometry(PgGeometry geom)
Assign a geometry on which this workshop operates,- Specified by:
setGeometryin interfacePjWorkshopIf- Overrides:
setGeometryin classPjWorkshop- Parameters:
geom- the workshop modifies this geometry.
-
reset
public void reset()
Reset workshop and geometry to original state. Initialize necessary data to run the snake game.- Overrides:
resetin classPjWorkshop
-
update
public boolean update(java.lang.Object event)
Update the class whenever a child has changed. Method is usually invoked from the children.- Specified by:
updatein interfacePsUpdateIf- Overrides:
updatein classPjWorkshop- Parameters:
event- sender of this update.- Returns:
- true if update was correctly handled by superclass.
- See Also:
PsObject.setParent(PsUpdateIf),PsObject.getFather(),PsObject.addUpdateListener(PsUpdateIf)
-
setDisplay
public void setDisplay(PvDisplayIf display)
Store currently active display. This is necessary to get key events.- Specified by:
setDisplayin interfacePjWorkshopIf- Overrides:
setDisplayin classPjWorkshop
-
close
public void close()
Remove key listener from display, reset elementSet to state before starting the game, and destroy dialog window.- Overrides:
closein classPjWorkshop
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
Store, if "Right" or "Left" key is pressed.- Specified by:
keyPressedin interfacejava.awt.event.KeyListener
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
Store, if "Right" or "Left" key is pressed.- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
Just to fulfill KeyListener interface.- Specified by:
keyTypedin interfacejava.awt.event.KeyListener
-
start
public void start()
Start snake game in separate thread.
-
stop
public void stop()
Stop snake game in separate thread.
-
pause
public void pause()
Pauses the game.
-
resume
public void resume()
Resumes a paused game.
-
run
public void run()
Run the snake until it dies.- Specified by:
runin interfacejava.lang.Runnable
-
-
"