fi.utu.cs.asteroids
Class Projectile

java.lang.Object
  |
  +--fi.utu.cs.physics.Body
        |
        +--fi.utu.cs.physics.MomentaryBody
              |
              +--fi.utu.cs.asteroids.Projectile
All Implemented Interfaces:
Shapable

public class Projectile
extends MomentaryBody
implements Shapable

A projectile. The lifetime of the projectiles is defined by the parameter projectileLifetime.


Constructor Summary
Projectile(Point2 p, double t, Ship s)
          Creates a projectile at the position p heading at the direction of the angle t and launched by the ship s.
 
Method Summary
 java.awt.Color color()
          Returns a Color object that is used for drawing the outline.
 void die()
          Removes this projectile from the universe.
 Ship getLauncher()
          Returns the ship that launched this projectile.
 boolean isColliding(Body other)
          Returns whether the projectile collides with the body other.
 boolean isDrawn()
          Returns a boolean value indicating whether the outline of the shape is drawn or not.
 boolean isFilled()
          Returns a boolean value indicating whether the shape is filled or not.
 java.awt.Paint paint()
          Returns a Paint object that is used for filling the shape.
 java.awt.Shape shape()
          Returns a Shape object that defines the appearance of the object.
 java.awt.Stroke stroke()
          Returns a Stroke object that is used for drawing the outline.
 java.lang.String toString()
          Returns a string that contains the values of the attributes.
 
Methods inherited from class fi.utu.cs.physics.MomentaryBody
advance, getLifetime, setLifetime
 
Methods inherited from class fi.utu.cs.physics.Body
elasticCollision, getAcceleration, getMass, getOwner, getPosition, getRadius, getVelocity, isCorporeal, isOverlapping, setAcceleration, setAcceleration, setCorporeal, setEthereal, setMass, setOwner, setPosition, setPosition, setRadius, setVelocity, setVelocity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Projectile

public Projectile(Point2 p,
                  double t,
                  Ship s)
Creates a projectile at the position p heading at the direction of the angle t and launched by the ship s. The mass of the projectile is defined by the parameter projectileMass and the size by the parameter projectileRadius. The created projectile uses the initial velocity and acceleration defined in the parameters projectileInitialVelocity and projectileInitialAcceleration. The angle is in radians.
See Also:
Game
Method Detail

getLauncher

public Ship getLauncher()
Returns the ship that launched this projectile.

die

public void die()
Removes this projectile from the universe.
Overrides:
die in class MomentaryBody

isColliding

public boolean isColliding(Body other)
Returns whether the projectile collides with the body other. When a projectile hits an asteroid, the projectile is removed. The parameter collisionProjectileShip defines, whether the ships can collide with the projectiles. The parameter collisionProjectileProjectile defines, whether the projectiles can collide with each other.
Overrides:
isColliding in class Body
See Also:
Asteroid, Ship, die()

shape

public java.awt.Shape shape()
Description copied from interface: Shapable
Returns a Shape object that defines the appearance of the object.
Specified by:
shape in interface Shapable
Following copied from interface: fi.utu.cs.appearance.Shapable
See Also:
Shape

isDrawn

public boolean isDrawn()
Description copied from interface: Shapable
Returns a boolean value indicating whether the outline of the shape is drawn or not.
Specified by:
isDrawn in interface Shapable
Following copied from interface: fi.utu.cs.appearance.Shapable
See Also:
Shapable.stroke(), Shapable.color()

stroke

public java.awt.Stroke stroke()
Description copied from interface: Shapable
Returns a Stroke object that is used for drawing the outline.
Specified by:
stroke in interface Shapable
Following copied from interface: fi.utu.cs.appearance.Shapable
See Also:
Shapable.isDrawn(), Stroke

color

public java.awt.Color color()
Description copied from interface: Shapable
Returns a Color object that is used for drawing the outline.
Specified by:
color in interface Shapable
Following copied from interface: fi.utu.cs.appearance.Shapable
See Also:
Shapable.isDrawn(), Color

isFilled

public boolean isFilled()
Description copied from interface: Shapable
Returns a boolean value indicating whether the shape is filled or not.
Specified by:
isFilled in interface Shapable
Following copied from interface: fi.utu.cs.appearance.Shapable
See Also:
Shapable.paint()

paint

public java.awt.Paint paint()
Description copied from interface: Shapable
Returns a Paint object that is used for filling the shape.
Specified by:
paint in interface Shapable
Following copied from interface: fi.utu.cs.appearance.Shapable
See Also:
Shapable.isFilled(), Paint

toString

public java.lang.String toString()
Description copied from class: Body
Returns a string that contains the values of the attributes.
Overrides:
toString in class Body