org.haphazard.gui.engine
Class MoveableGraphicalObject

java.lang.Object
  extended byorg.haphazard.gui.engine.GraphicalObject
      extended byorg.haphazard.gui.engine.MoveableGraphicalObject
Direct Known Subclasses:
Character

public class MoveableGraphicalObject
extends GraphicalObject

This class handles all the dynamic graphical objects like character or enemys


Field Summary
protected  Vector3D mFacing
           
protected  Point3D mLocation
           
protected  Map mMap
           
protected  Vector3D mSpeedVector
           
 boolean mUseFogOfWar
           
 
Fields inherited from class org.haphazard.gui.engine.GraphicalObject
id, mDefaultSprite, mDescription, mDescriptionColor, mDescriptionDisplayTime, mDescriptionStartTime, mDimension, mLink, mName, mSpriteDisplayed, mSprites, mWeight
 
Constructor Summary
MoveableGraphicalObject()
          Default constructor
MoveableGraphicalObject(Sprite defaultSprite)
          The constructor that handles all initilization
MoveableGraphicalObject(java.lang.String name)
          The constructor that handles all initilization from a XML-file NOTE: This is using GlobalWorld.getCurrentMap() to set this object on the map so
 
Method Summary
 Vector3D getFacing()
          Gets the facing of this object
 Point3D getLocation()
          Finds the tile the character currently resides in
 Map getMap()
          Gets the map the character currently resides on
 void load(java.io.InputStream stream)
          Loads an object from a file
static GraphicalObject loadInstance(java.io.InputStream stream)
          Loads an object from a file
 boolean paintComponent(java.awt.Graphics2D g, Map map, java.awt.Point middleTileCoordinate)
          paints the component on the screen.
 boolean paintComponent(java.awt.Graphics2D g, Map map, java.util.Vector topToLeft, java.util.Vector rightToBottom, java.awt.Point middleTileCoordinate)
          paints the component on the screen.
 void setFacing(Point3D point)
          Makes the character face a point
 void setLocation(Point3D location, Map map)
          Sets the characters location in the world
 void setSpeed(Vector3D speed)
          Sets the characters speed
 java.lang.String toXML(int indent)
          Transforms this object into XML-notation
 void update()
          Updates this character Should be called every frame update
 
Methods inherited from class org.haphazard.gui.engine.GraphicalObject
addSprite, combineSprites, displayDescription, displaySprite, getAvailableSprites, getBoundingBox, getDescription, getDimension, getName, getNotResettedSprite, getResettedSprite, getWeight, isDefaultSpriteDisplayed, optimize, resetDisplayedSprite, save, setDefaultSprite, setDefaultSprite, setDescription, setDimension, setName, setWeight, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mLocation

protected Point3D mLocation

mSpeedVector

protected Vector3D mSpeedVector

mFacing

protected Vector3D mFacing

mMap

protected Map mMap

mUseFogOfWar

public boolean mUseFogOfWar
Constructor Detail

MoveableGraphicalObject

public MoveableGraphicalObject()
Default constructor


MoveableGraphicalObject

public MoveableGraphicalObject(Sprite defaultSprite)
The constructor that handles all initilization

Parameters:
defaultSprite - The Sprite to set as default

MoveableGraphicalObject

public MoveableGraphicalObject(java.lang.String name)
The constructor that handles all initilization from a XML-file NOTE: This is using GlobalWorld.getCurrentMap() to set this object on the map so

Parameters:
name - the name of the object
Method Detail

setLocation

public void setLocation(Point3D location,
                        Map map)
Sets the characters location in the world

Parameters:
map - The map the tile exists in

getLocation

public Point3D getLocation()
Finds the tile the character currently resides in

Returns:
A point containing the coordinates

setSpeed

public void setSpeed(Vector3D speed)
Sets the characters speed

Parameters:
speed - The speed to set

getFacing

public Vector3D getFacing()
Gets the facing of this object

Returns:
The facing

setFacing

public void setFacing(Point3D point)
Makes the character face a point

Parameters:
point - The point to turn the character towards

getMap

public Map getMap()
Gets the map the character currently resides on


update

public void update()
Updates this character Should be called every frame update


paintComponent

public boolean paintComponent(java.awt.Graphics2D g,
                              Map map,
                              java.awt.Point middleTileCoordinate)
paints the component on the screen.

Overrides:
paintComponent in class GraphicalObject
Parameters:
g - The graphics to use to paint with
map - the ground that "draw" this DGO. This is needed for displacement
middleTileCoordinate - The middle coordinate of the tile the object is residing on
Returns:
true if the image is changed during painting

paintComponent

public boolean paintComponent(java.awt.Graphics2D g,
                              Map map,
                              java.util.Vector topToLeft,
                              java.util.Vector rightToBottom,
                              java.awt.Point middleTileCoordinate)
paints the component on the screen.

Parameters:
g - The graphics to use to paint with
map - the map that "draw" this DGO. This is needed for displacement

load

public void load(java.io.InputStream stream)
Loads an object from a file

Overrides:
load in class GraphicalObject
Parameters:
stream - The stream to load

loadInstance

public static GraphicalObject loadInstance(java.io.InputStream stream)
Loads an object from a file

Parameters:
stream - The stream to load from
Returns:
The loaded instance

toXML

public java.lang.String toXML(int indent)
Transforms this object into XML-notation

Overrides:
toXML in class GraphicalObject
Parameters:
indent - The level of indentation to use
Returns:
The object in a String notation