simworldobjects
Class BasicSimWorld

java.lang.Object
  extended bysimworldobjects.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 modified by: Simon Zienkiewicz
See Also:
SimWorld

Constructor Summary
BasicSimWorld(long x, long y, long z)
          Sets up the basic sim world
BasicSimWorld(long x, long y, long z, java.awt.Color c)
          Sets up the basic sim world Created by: Simon Zienkiewicz
 
Method Summary
 void addObject(SimObject s)
          Adds an object to the back of this SimWorld
 void addObjecttoFront(SimObject s)
          Adds an object to the front of any Robot object/part in the list Added by: Simon Zienkiewicz
 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.awt.Color getColorUnderLightSensor(SimLightSensor lightSensor)
          Gets the color under the position of the light sensor
 java.util.LinkedList getObjectList()
          Returns this SimWorld's object list
 long getTime()
          Returns the number of 'ticks' since this world was started
 java.awt.Color getWorldColor()
          Gets the ground color of the world Created by: Simon Zienkiewicz
 int[] getWorldDimensions()
          Gets the dimensions of the world Created by: Simon Zienkiewicz
 boolean hasObstacle(double x, double y, double z)
          Checks whether there is an obstacle in the specified co-ordinate
 void setWorldColor(java.awt.Color color)
          Sets the ground color of the world Created by: Simon Zienkiewicz
 void tick()
          Performs one update loop
 void updateObjectList(java.util.LinkedList newList)
           
 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

BasicSimWorld

public BasicSimWorld(long x,
                     long y,
                     long z,
                     java.awt.Color c)
Sets up the basic sim world Created by: Simon Zienkiewicz

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
c - the Color of the ground of the 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
Parameters:
x - the x coordinate of position searched
y - the y coordinate of position searched
z - the z coordinate of position searched
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 the back of this SimWorld

Specified by:
addObject in interface SimWorld
Parameters:
s - the SimObject to be added

addObjecttoFront

public void addObjecttoFront(SimObject s)
Adds an object to the front of any Robot object/part in the list Added by: Simon Zienkiewicz


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


getColorUnderLightSensor

public java.awt.Color getColorUnderLightSensor(SimLightSensor lightSensor)
Gets the color under the position of the light sensor

Parameters:
lightSensor - the light sensor object

getWorldColor

public java.awt.Color getWorldColor()
Gets the ground color of the world Created by: Simon Zienkiewicz

Specified by:
getWorldColor in interface SimWorld
Returns:
Colour the background colour of the current world

setWorldColor

public void setWorldColor(java.awt.Color color)
Sets the ground color of the world Created by: Simon Zienkiewicz


getWorldDimensions

public int[] getWorldDimensions()
Gets the dimensions of the world Created by: Simon Zienkiewicz

Returns:
the dimensions of the world

updateObjectList

public void updateObjectList(java.util.LinkedList newList)