gizmoball.gameworld.gameobjects
Class Ball

java.lang.Object
  extended by gizmoball.gameworld.GameObject
      extended by gizmoball.gameworld.gameobjects.Ball
Direct Known Subclasses:
EnemyShot, SimpleBall

public abstract class Ball
extends GameObject

This is the base interface for all balls in the game world. All balls are assumed to be spheres.

Specification Fields :
sphere : PhysicsSphere // the sphere object that is this ball

Constructor Summary
Ball()
           
 
Method Summary
abstract  Vect3 getGravity()
          Gets the gravity this ball is currently operating under.
abstract  PhysicsSphere getSphere()
          Returns the sphere representing this ball.
abstract  void setFriction(double mu, double mu2)
          Sets the friction for this ball.
abstract  void setGravity(Vect3 g)
          Sets the gravity for this ball to be the specified value.
abstract  void setPosition(Vect3 newPosition)
          Sets the position of the ball to now be a new position.
abstract  void setVelocity(Vect3 newVelocity)
          Sets the velocity of the ball to now be a new velocity.
 
Methods inherited from class gizmoball.gameworld.GameObject
copy, getBoundingBox, getDefaultTriggers, getGraphicsProperties, getXMLString, toString, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ball

public Ball()
Method Detail

getSphere

public abstract PhysicsSphere getSphere()
Returns the sphere representing this ball. It contains the position, velocity, and rotation of the sphere.

Returns:
this.sphere

setVelocity

public abstract void setVelocity(Vect3 newVelocity)
Sets the velocity of the ball to now be a new velocity.

Effects:
changes the velocity of the ball to be newVelocity

setPosition

public abstract void setPosition(Vect3 newPosition)
Sets the position of the ball to now be a new position.

Effects:
changes the position of the ball to be newPosition

setGravity

public abstract void setGravity(Vect3 g)
Sets the gravity for this ball to be the specified value. Units are L/sec^2.

Effects:
sets how quickly this ball accelerates due to gravity

getGravity

public abstract Vect3 getGravity()
Gets the gravity this ball is currently operating under.


setFriction

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

Effects:
changes the friction that acts on the ball