org.game.JVirus
Class ActionControl

java.lang.Object
  |
  +--org.game.JVirus.ActionControl
All Implemented Interfaces:
java.util.EventListener, IFields, java.awt.event.KeyListener

public class ActionControl
extends java.lang.Object
implements IFields, java.awt.event.KeyListener

this class controls the movement of the avatar and the animating thread.


Inner Class Summary
protected  class ActionControl.ActionControlRunner
          Animating thread
static interface ActionControl.IGameListener
          callback interface for game events
 
Field Summary
protected  Avatar avatar
          reference to the Avatar
protected  Display display
          reference to the display
protected  ActionControl.IGameListener gameListener
          callback function
protected  boolean gamePaused
          game paused or not
protected  boolean gameStart
          game running or not
protected  long lastTimeAvatarMove
          need to escape from stones
protected  Matrix level
          reference to the level
protected  javax.swing.JFrame parent
          reference to the JVirusFrame
protected  ActionControl.ActionControlRunner runner
          thread to for animated objects
protected  int set_byte
          clear byte
 
Fields inherited from interface org.game.JVirus.IFields
AMD, AT_ACTION, AT_ANIM, AT_BEAM, AT_EAT, AT_EAT_SOUND1, AT_EAT_SOUND2, AT_END, AT_FAll, AT_HOLD, AT_MOVE, AT_PUSH, AT_WALL, BEAM0, BEAM1, BEAM2, BEAM3, BEAM4, BEAM5, BEAM6, BEAM7, BEAM8, BEAM9, BEOS, BLUEGATE, BLUEKEY, DATA1, DATA2, DATA3, DYNS1, DYNS2, DYNS3, DYNS4, DYNT1, DYNT2, DYNT3, DYNT4, EMPTY, END, GREENGATE, GREENKEY, INTEL, LIFE, LINUX, MAC, NOTHING, REDGATE, REDKEY, START, STONE, TREASURE, UNIX, WALL1, WALL2, WALL3, WALL4, WALL5, WINDOWS
 
Constructor Summary
ActionControl(Display display, javax.swing.JFrame parent, ActionControl.IGameListener gameListener)
          creates the ActionControl.
 
Method Summary
protected  boolean actionAvatar(int sx, int sy, int tx, int ty)
          select what Action to do in this field
protected  void beamAvatar(char key, int x, int y)
          search for other beam field and move the avatar
protected  void gameOver(int reason)
          edit the avatar and call the callback funktion
 Avatar getAvatar()
          return the current avatar
 boolean isPaused()
          is the game paused or not
 boolean isRunning()
          is the game started or not
 void keyPressed(java.awt.event.KeyEvent e)
          get the key events
 void keyReleased(java.awt.event.KeyEvent e)
          not used
 void keyTyped(java.awt.event.KeyEvent e)
          not used
protected  void moveAvatar(int sx, int sy, int tx, int ty)
          next move from user
protected  void nextMove()
          next move from thread
 void pauseGame(boolean b)
          pause the game
protected  void removeGate(char key)
          search for the gate that pass and remove that
 void resetAvatar()
          reset the scores and lifes of the avatar.
 void startGame(Matrix level)
          start the game
 void stopGame()
          stop the game
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

level

protected Matrix level
reference to the level
See Also:
Matrix

display

protected Display display
reference to the display
See Also:
Display

parent

protected javax.swing.JFrame parent
reference to the JVirusFrame
See Also:
JVirusFrame

avatar

protected Avatar avatar
reference to the Avatar
See Also:
Avatar

gameListener

protected ActionControl.IGameListener gameListener
callback function

runner

protected ActionControl.ActionControlRunner runner
thread to for animated objects

set_byte

protected int set_byte
clear byte
See Also:
nextMove()

gameStart

protected boolean gameStart
game running or not

gamePaused

protected boolean gamePaused
game paused or not

lastTimeAvatarMove

protected long lastTimeAvatarMove
need to escape from stones
See Also:
nextMove()
Constructor Detail

ActionControl

public ActionControl(Display display,
                     javax.swing.JFrame parent,
                     ActionControl.IGameListener gameListener)
creates the ActionControl.
Parameters:
display - reference to the Display
parent - reference to the JVirusFrame
gameListener - reference to the callback function
Method Detail

getAvatar

public Avatar getAvatar()
return the current avatar
See Also:
Avatar

startGame

public void startGame(Matrix level)
start the game
Parameters:
level - playing level

pauseGame

public void pauseGame(boolean b)
pause the game
Parameters:
b - pause or not

resetAvatar

public void resetAvatar()
reset the scores and lifes of the avatar.

stopGame

public void stopGame()
stop the game

isRunning

public boolean isRunning()
is the game started or not

isPaused

public boolean isPaused()
is the game paused or not

gameOver

protected void gameOver(int reason)
edit the avatar and call the callback funktion

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
get the key events
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
not used
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
not used
Specified by:
keyTyped in interface java.awt.event.KeyListener

nextMove

protected void nextMove()
next move from thread

moveAvatar

protected void moveAvatar(int sx,
                          int sy,
                          int tx,
                          int ty)
next move from user

actionAvatar

protected boolean actionAvatar(int sx,
                               int sy,
                               int tx,
                               int ty)
select what Action to do in this field

removeGate

protected void removeGate(char key)
search for the gate that pass and remove that

beamAvatar

protected void beamAvatar(char key,
                          int x,
                          int y)
search for other beam field and move the avatar