netwar.game
Class Projectile

java.lang.Object
  |
  +--netwar.game.Projectile
Direct Known Subclasses:
ProjectileDefault, ProjectileDefault2

public abstract class Projectile
extends java.lang.Object

Abstract class representing one shot fired from some weapon.

Author:
Group N2 - Project Netwar, Daniel Grund

Field Summary
protected  Point3D center
          The game-space location of the center of the projectile.
protected  int damage
          The amount of damage the shot will deal if it hits something.
protected  GameObject enemy
          The object that the shot was intended to hit (in case it is relevant)
protected  int life
          The number of frames remaining before this projectile must cease existing (it may cease before then)
protected  GameObject maker
          The object that fired this shot (in case it is relevant)
protected static Vector Projectiles
          The vector containing all currently existing Projectiles.
protected  int radiusSquared
          The square of the radius of explosion for this shot.
protected  Point3D velocity
          The velocity of the projectile, in game-space units per time-step
 
Constructor Summary
Projectile()
           
 
Method Summary
protected  boolean basicUpdate()
          Performs functions which will be needed by most Projectiles during Update().
abstract  void draw(GameViewer v)
          Displays this projectile on GameViewer v.
static void DrawAll(GameViewer v)
          Draws all projectiles in the game onto GameViewer v
protected abstract  void Explode()
          Deals damage to nearby GameObjects, makes flashy graphics, and calls Fizzle().
protected  void Fizzle()
          Removes this from the game
protected abstract  boolean mustExplode()
          Return true iff it should detonate when it's life runs out.
static void newProjectile(Projectile add, Point3D where, Point3D going, int power, int rad2, int duration, GameObject origin, GameObject target)
          This method initializes a Projectile.
protected abstract  void Update()
          Function to perform the processing needed during a single time-step.
static void UpdateAll()
          Calls update() on all Projectiles in the Vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

center

protected Point3D center
The game-space location of the center of the projectile.

velocity

protected Point3D velocity
The velocity of the projectile, in game-space units per time-step

maker

protected GameObject maker
The object that fired this shot (in case it is relevant)

enemy

protected GameObject enemy
The object that the shot was intended to hit (in case it is relevant)

life

protected int life
The number of frames remaining before this projectile must cease existing (it may cease before then)

damage

protected int damage
The amount of damage the shot will deal if it hits something.

radiusSquared

protected int radiusSquared
The square of the radius of explosion for this shot.

Projectiles

protected static Vector Projectiles
The vector containing all currently existing Projectiles.
Constructor Detail

Projectile

public Projectile()
Method Detail

newProjectile

public static void newProjectile(Projectile add,
                                 Point3D where,
                                 Point3D going,
                                 int power,
                                 int rad2,
                                 int duration,
                                 GameObject origin,
                                 GameObject target)
This method initializes a Projectile. This performs the following processes:
Initializes the center, velocity, damage, radiusSquared, life, maker, and enemy fields.
Adds the Projectile into the Vector.
Parameters:
add - The Projectile to incorporate into the game.
where - The initial value of center.
going - The initial value of velocity.
power - The initial value of damage.
rad2 - The initial value of radiusSquared.
duration - The initial value of life.
origin - The initial value of maker.
target - The initial value of enemy.

UpdateAll

public static void UpdateAll()
Calls update() on all Projectiles in the Vector.

basicUpdate

protected boolean basicUpdate()
Performs functions which will be needed by most Projectiles during Update(). Specifically, it decrements life. If life reaches zero, it calls Explode() if mustExplode() returns true, Fizzle() if mustExplode() returns false. Then it returns false. If life did not reach zero, it returns true.

Update

protected abstract void Update()
Function to perform the processing needed during a single time-step.

DrawAll

public static void DrawAll(GameViewer v)
Draws all projectiles in the game onto GameViewer v
Parameters:
v - The GameViewer seeking to display all the Projectiles.

draw

public abstract void draw(GameViewer v)
Displays this projectile on GameViewer v.
Parameters:
v - The GameViewer seeking to display this Projectile.

mustExplode

protected abstract boolean mustExplode()
Return true iff it should detonate when it's life runs out.
Returns:
true if this should not just Fizzle() when life runs out.

Explode

protected abstract void Explode()
Deals damage to nearby GameObjects, makes flashy graphics, and calls Fizzle().

Fizzle

protected void Fizzle()
Removes this from the game