fi.utu.cs.asteroids
Class Asteroid

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

public class Asteroid
extends Body
implements Shapable

An asteroid. The properties of the asteroids are defined by the parameters asteroidMinimumMass, asteroidMaximumMass, and asteroidsDensity.


Constructor Summary
Asteroid(double m, Point2 p, double t)
          Creates an asteroid with the mass m at the position p heading at the direction of the angle t.
 
Method Summary
 java.awt.Color color()
          Returns a Color object that is used for drawing the outline.
 boolean isColliding(Body other)
          Returns whether the asteroid 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.
 void split()
          Splits the asteroid.
 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.Body
advance, 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

Asteroid

public Asteroid(double m,
                Point2 p,
                double t)
Creates an asteroid with the mass m at the position p heading at the direction of the angle t. The created asteroid uses the initial velocity and acceleration defined in the parameters asteroidInitialVelocity and asteroidInitialAcceleration. The angle is in radians.
See Also:
Game
Method Detail

isColliding

public boolean isColliding(Body other)
Returns whether the asteroid collides with the body other. When an asteroid hits a projectile, the asteroid is split. The parameter collisionAsteroidAsteroid defines, whether the asteroids can collide with each other.
Overrides:
isColliding in class Body
See Also:
Projectile, split()

split

public void split()
Splits the asteroid. After the split, the original asteroid is removed from the universe and replaced with fractions defined by the parameters asteroidMinFractionOnSplit, asteroidMaxFractionOnSplit, and asteroidSumOfFractionsOnSplit. If the parameter decorations is true, a cloud of debris is created at the site of the split according to the parameters debrisOnCloud and debrisMaxVelocity.
See Also:
Debris

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