gizmoball.gameworld
Class Gizmo

java.lang.Object
  extended by gizmoball.gameworld.GameObject
      extended by gizmoball.gameworld.Gizmo
Direct Known Subclasses:
BallShooter, CircleBumperGizmo, CubeBumperGizmo, DetectorPlane, DonutBumperGizmo, EnemyShip, Flipper, GhostBallGizmo, MonkeyBallGizmo, Paddle, PeriodicTriggerGizmo, RectangleBumperGizmo, ShipGizmo, SphereBumperGizmo, ToggleGizmo, TriangleBumperGizmo, Walls

public abstract class Gizmo
extends GameObject

This is the base interface for all gizmos. Every gizmo is assumed to "activate", even if being activated means nothing.

Specification Fields

Field Summary
protected  double orientation
           
protected  Vect3 totalTranslation
           
 
Constructor Summary
Gizmo()
           
 
Method Summary
 void activate()
          Activates this Gizmo, taking into account the time delay.
 GameObject copy()
          Returns a copy of this GameObject.
abstract  void doActivate()
          Immediately "activates" this gizmo.
protected abstract  void doUpdate(double dt)
          The same as GameObject.update().
 Vect3Pair getBoundingBox()
          Returns the bounding box of this
protected  java.lang.String getCoeffReflectionString()
           
protected  java.lang.String getColorString()
           
 java.lang.String getCommonAttributesString()
           
 java.util.List<Trigger> getDefaultTriggers()
          Default gizmos have no triggers
protected  java.lang.String getOrientationDoubleString()
           
protected  java.lang.String getOrientationString()
           
abstract  PhysicsModel getPhysicsModel()
          Returns the physical model of this gizmo.
 double getReflectionCoeff()
           
protected  java.lang.String getTextureString()
           
protected  java.lang.String getTranslationString()
           
 int getXMLDelay()
          Returns the delay of this gizmo in milliseconds
protected  java.lang.String getXMLDelayString()
           
 void rotateAboutAxis(Vect3 center, Vect3 axis, double angle)
          Rotates this
 void setCoefficientOfReflection(double d)
          Sets the coefficient of reflection of this
 void setCommonAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
          Sets a group of common attributes.
 void setDelay(double delay)
          Sets the delay between a call to this.activate() and the actual activization.
 void translateBy(Vect3 v)
          Translates this
 void update(double dt)
          Updates this gizmo.
 
Methods inherited from class gizmoball.gameworld.GameObject
getGraphicsProperties, getXMLString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

totalTranslation

protected Vect3 totalTranslation

orientation

protected double orientation
Constructor Detail

Gizmo

public Gizmo()
Method Detail

getPhysicsModel

public abstract PhysicsModel getPhysicsModel()
Returns the physical model of this gizmo. The model stores the structure, as well as velocity, rotation, and rotation of this gizmo.

Returns:
this.physicsModel

doUpdate

protected abstract void doUpdate(double dt)
The same as GameObject.update().


doActivate

public abstract void doActivate()
Immediately "activates" this gizmo. The definition of "activate" varies from gizmo to gizmo.

Effects:
"activates" this gizmo

setDelay

public void setDelay(double delay)
Sets the delay between a call to this.activate() and the actual activization. The default delay is 0.

Effects:
this.delay = delay

activate

public final void activate()
Activates this Gizmo, taking into account the time delay.

Effects:
adds a delay to this.delays

update

public final void update(double dt)
Updates this gizmo. Handles the time delay.

Specified by:
update in class GameObject
Parameters:
dt - the amount to move forward in time
Requires:
dt >= 0
Effects:
performs the update operation, which varies from gizmo to gizmo

translateBy

public void translateBy(Vect3 v)
Translates this

Requires:
v != null
Effects:
translates this.physicsModel by v

getTranslationString

protected java.lang.String getTranslationString()

getOrientationString

protected java.lang.String getOrientationString()

getOrientationDoubleString

protected java.lang.String getOrientationDoubleString()

getCoeffReflectionString

protected java.lang.String getCoeffReflectionString()

getXMLDelayString

protected java.lang.String getXMLDelayString()

getTextureString

protected java.lang.String getTextureString()

getColorString

protected java.lang.String getColorString()

setCommonAttributes

public void setCommonAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
Sets a group of common attributes. Used by XML

Parameters:
attributes - A map between the names of common attributes and their assigned values
Effects:
sets the attributes to their desired values

getCommonAttributesString

public java.lang.String getCommonAttributesString()
Returns:
an XML string encapsulating information about four common attributes

rotateAboutAxis

public void rotateAboutAxis(Vect3 center,
                            Vect3 axis,
                            double angle)
Rotates this

Requires:
center, axis != null
Effects:
rotates this about the line defined by center and axis by "angle" radians

getReflectionCoeff

public double getReflectionCoeff()
Returns:
this.reflectionCoeff

copy

public GameObject copy()
Description copied from class: GameObject
Returns a copy of this GameObject. It is not just a shallow copy, but not necessarily a complete deep copy. Some things are guaranteed to be deep copied, such as balls. Some things, like references to gizmos, should not and will not be copied.

Specified by:
copy in class GameObject
Returns:
a copy of this

setCoefficientOfReflection

public void setCoefficientOfReflection(double d)
Sets the coefficient of reflection of this

Requires:
0 <= d <= 1
Effects:
this.reflectionCoeff = d

getXMLDelay

public int getXMLDelay()
Returns the delay of this gizmo in milliseconds

Returns:
delay*1000 cast to integer

getBoundingBox

public Vect3Pair getBoundingBox()
Description copied from class: GameObject
Returns the bounding box of this

Specified by:
getBoundingBox in class GameObject
Returns:
a bounding box for this

getDefaultTriggers

public java.util.List<Trigger> getDefaultTriggers()
Default gizmos have no triggers

Specified by:
getDefaultTriggers in class GameObject
Returns:
an empty list