simworldobjects
Class BasicSimWorld

java.lang.Object
  |
  +--simworldobjects.BasicSimWorld
All Implemented Interfaces:
SimWorld

public abstract class BasicSimWorld
extends java.lang.Object
implements SimWorld

Abstract class for SimWorlds, provides a base implementation of the SimWorld interface which more complex worlds can extend. (e.g by adding lights, walls etc.)

Author:
Graham Ritchie
See Also:
SimWorld

Constructor Summary
BasicSimWorld(long x, long y, long z)
          Sets up the basic sim world
 
Method Summary
 void addObject(SimObject s)
          Adds an object to this SimWorld
 boolean colliding(SimObject o, SimObject p)
          Checks if SimObject o is colliding with SimObject p.
 int getBrightness(double x, double y, double z)
          Returns the light level at the specified co-ordinate.
 java.util.LinkedList getObjectList()
          Returns this SimWorld's object list
 long getTime()
          Returns the number of 'ticks' since this world was started
 boolean hasObstacle(double x, double y, double z)
          Checks whether there is an obstacle in the specified co-ordinate
 void tick()
          Performs one update loop
 void updateObjects()
          Updates all the SimObjects in this world by one step
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicSimWorld

public BasicSimWorld(long x,
                     long y,
                     long z)
Sets up the basic sim world
Parameters:
x - the largest x cooridnate in this world
y - the largest y cooridnate in this world
z - the largest z cooridnate in this world
Method Detail

tick

public void tick()
Performs one update loop
Specified by:
tick in interface SimWorld

getTime

public long getTime()
Returns the number of 'ticks' since this world was started
Specified by:
getTime in interface SimWorld
Returns:
the number of ticks as a long

getBrightness

public int getBrightness(double x,
                         double y,
                         double z)
Returns the light level at the specified co-ordinate.
Specified by:
getBrightness in interface SimWorld
Returns:
the brightness, this will always be an int between 0 and 100

hasObstacle

public boolean hasObstacle(double x,
                           double y,
                           double z)
Checks whether there is an obstacle in the specified co-ordinate
Specified by:
hasObstacle in interface SimWorld
Parameters:
x - the x coordinate
y - the y coordinate
z - the z coordinate
Returns:
true or false accordingly

colliding

public boolean colliding(SimObject o,
                         SimObject p)
Checks if SimObject o is colliding with SimObject p.
Parameters:
o - the first SimObject
p - the second SimObject
Returns:
true or false accordingly

addObject

public void addObject(SimObject s)
Adds an object to this SimWorld
Specified by:
addObject in interface SimWorld
Parameters:
o - the SimObject to be added

getObjectList

public java.util.LinkedList getObjectList()
Returns this SimWorld's object list
Specified by:
getObjectList in interface SimWorld
Returns:
the object list as a LinkedList

updateObjects

public void updateObjects()
Updates all the SimObjects in this world by one step