gizmoball.gameworld.gameobjects
Class EnemyShot

java.lang.Object
  extended by gizmoball.gameworld.GameObject
      extended by gizmoball.gameworld.gameobjects.Ball
          extended by gizmoball.gameworld.gameobjects.EnemyShot

public class EnemyShot
extends Ball

This is an implementation of the Ball interface to be used as shots in Multiplayer Space Invaders. Each EnemyShot must be equipped with an AnnihilateBothTrigger.

Specification Fields

Constructor Summary
EnemyShot(Vect3 position)
          Creates a simple ball with the specified location.
EnemyShot(Vect3 position, Vect3 velocity)
          Creates a simple ball with the specified location and velocity.
EnemyShot(Vect3 position, Vect3 velocity, Vect3 gravity, double frictionMu, double frictionMu2)
          Creates a simple ball with the specified location, velocity, and gravity/friction constants.
 
Method Summary
 GameObject copy()
          Returns a copy of this GameObject.
 Vect3Pair getBoundingBox()
          Returns the bounding box of this
 java.util.List<Trigger> getDefaultTriggers()
          Doesn't return the necessary AnnihilateBothTrigger, since EnemyShot has no access to the WorldState.
 GraphicsProperties getGraphicsProperties()
          Returns an object that holds the information necessary for drawing this object.
 Vect3 getGravity()
          Gets the gravity this ball is currently operating under.
 PhysicsSphere getSphere()
          Returns the sphere representing this ball.
 java.lang.String getXMLString(java.lang.String name)
          returns the XML string that would be used to save this game object
 void setFriction(double mu, double mu2)
          Sets the friction for this ball.
 void setGravity(Vect3 g)
          Sets the gravity for this ball to be the specified value.
 void setPosition(Vect3 newPosition)
          Sets the position of the ball to now be a new position.
 void setVelocity(Vect3 newVelocity)
          Sets the velocity of the ball to now be a new velocity.
 void update(double dt)
          This has the GameObject update its internal state, to move forward in time by an amount dt.
 
Methods inherited from class gizmoball.gameworld.GameObject
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EnemyShot

public EnemyShot(Vect3 position)
Creates a simple ball with the specified location.


EnemyShot

public EnemyShot(Vect3 position,
                 Vect3 velocity)
Creates a simple ball with the specified location and velocity.


EnemyShot

public EnemyShot(Vect3 position,
                 Vect3 velocity,
                 Vect3 gravity,
                 double frictionMu,
                 double frictionMu2)
Creates a simple ball with the specified location, velocity, and gravity/friction constants.

Method Detail

getGraphicsProperties

public GraphicsProperties getGraphicsProperties()
Description copied from class: GameObject
Returns an object that holds the information necessary for drawing this object. Making changes to this object changes the underlying object, so those changes will be reflected in the drawer.

Specified by:
getGraphicsProperties in class GameObject
Returns:
all the information needed to draw this object.

getSphere

public PhysicsSphere getSphere()
Description copied from class: Ball
Returns the sphere representing this ball. It contains the position, velocity, and rotation of the sphere.

Specified by:
getSphere in class Ball
Returns:
this.sphere

setPosition

public void setPosition(Vect3 newPosition)
Description copied from class: Ball
Sets the position of the ball to now be a new position.

Specified by:
setPosition in class Ball

setVelocity

public void setVelocity(Vect3 newVelocity)
Description copied from class: Ball
Sets the velocity of the ball to now be a new velocity.

Specified by:
setVelocity in class Ball

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

update

public void update(double dt)
Description copied from class: GameObject
This has the GameObject update its internal state, to move forward in time by an amount dt. It is very important that the state variables used for this calculation are the same values as available before the calculation. For instance, when a ball is moving under the influence of gravity, update() must first move the ball, then update the velocity. This way if you try to externally calculate where the ball will be in a time dt, this will also be the position of the ball in time dt.

Specified by:
update in class GameObject
Parameters:
dt - the amount to move forward in time

setGravity

public void setGravity(Vect3 g)
Description copied from class: Ball
Sets the gravity for this ball to be the specified value. Units are L/sec^2.

Specified by:
setGravity in class Ball

getGravity

public Vect3 getGravity()
Description copied from class: Ball
Gets the gravity this ball is currently operating under.

Specified by:
getGravity in class Ball

setFriction

public void setFriction(double mu,
                        double mu2)
Description copied from class: Ball
Sets the friction for this ball. Friction works according to the rule: Vnew = Vold * (1 - mu * delta_t - mu2 * |Vold| * delta_t).

Specified by:
setFriction in class Ball

getXMLString

public java.lang.String getXMLString(java.lang.String name)
Description copied from class: GameObject
returns the XML string that would be used to save this game object

Specified by:
getXMLString in class GameObject
Returns:
String s where s is sufficient to be directly inserted into an XML file where game world information is being saved

getBoundingBox

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

Specified by:
getBoundingBox in class GameObject
Returns:
a Vect3Pair containing the coordinates of opposite corners of the box

getDefaultTriggers

public java.util.List<Trigger> getDefaultTriggers()
Doesn't return the necessary AnnihilateBothTrigger, since EnemyShot has no access to the WorldState.

Specified by:
getDefaultTriggers in class GameObject