|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--fi.utu.cs.physics.Body | +--fi.utu.cs.asteroids.Ship
A ship. The ship is steered with the methods rotateLeft
,
rotateRight
, and goStraight
; the thruster
is operated with the methods thrusterOn
, and
thrusterOff
; the firing is controled with the
methods fireOn
, and fireOff
; and the ship
is terminated with the method explode
.
Constructor Summary | |
Ship(Point2 p)
Creates a ship at position p pointing at a random
direction. |
Method Summary | |
void |
advance(double dt)
Advances the time dt seconds and updates the position,
velocity, and rotation of the ship accordingly. |
java.awt.Color |
color()
Returns a Color object that is used for drawing
the outline. |
void |
explode()
Explodes the ship and removes it from the universe. |
void |
fireOff()
Sets the firing off. |
void |
fireOn()
Sets the firing on. |
double |
getAngle()
Returns the current angle (in radians). |
void |
goStraight()
Sets the steering to straight forward. |
boolean |
isColliding(Body other)
Returns whether the ship 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. |
boolean |
isFiring()
Returns whether the ship is firing during the current update interval. |
boolean |
isThrusting()
Returns whether the thruster is on. |
java.awt.Paint |
paint()
Returns a Paint object that is used for filling
the shape. |
void |
rotateLeft()
Sets the steering to the left (i.e., counterclockwise). |
void |
rotateRight()
Sets the steering to the right (i.e., clockwise). |
void |
setAngle(double t)
Sets the current angle to t (in radians). |
void |
setColor(java.awt.Color c)
Sets the color of the ship to c . |
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. |
void |
thrusterOff()
Sets the thruster off. |
void |
thrusterOn()
Sets the thruster on. |
java.lang.String |
toString()
Returns a string that contains the values of the attributes. |
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 |
public Ship(Point2 p)
p
pointing at a random
direction. The mass of the ship is defined by the parameter
shipMass
and the size by the parameter
shipRadius
.Game
Method Detail |
public double getAngle()
public void setAngle(double t)
t
(in radians).public void setColor(java.awt.Color c)
c
.public void advance(double dt)
dt
seconds and updates the position,
velocity, and rotation of the ship accordingly. If the parameter
decorations
is true
and the thruster
is on, the ship emits a spark at the stern.advance
in class Body
thrusterOn()
,
Spark
public boolean isColliding(Body other)
other
.
The parameter collisionProjectileShip
defines,
whether the projectiles can collide with the ships.
The parameter collisionShipShip
defines,
whether the ships can collide with each other.isColliding
in class Body
Projectile
public void rotateLeft()
shipSteeringRotationPerSecond
.public void rotateRight()
shipSteeringRotationPerSecond
.public void goStraight()
public void thrusterOn()
shipThrusterForce
.public void thrusterOff()
public boolean isThrusting()
public void fireOn()
shipShotsPerSecond
.Projectile
public void fireOff()
public boolean isFiring()
fireOn()
,
advance(double)
public void explode()
decorations
is true
,
a cloud of sparks is created at the site of the explosion
according to the parameters sparksOnCloud
and
sparkMaxVelocity
.Spark
public java.awt.Shape shape()
Shapable
Shape
object that defines the appearance
of the object.shape
in interface Shapable
fi.utu.cs.appearance.Shapable
Shape
public boolean isDrawn()
Shapable
isDrawn
in interface Shapable
fi.utu.cs.appearance.Shapable
Shapable.stroke()
,
Shapable.color()
public java.awt.Stroke stroke()
Shapable
Stroke
object that is used for drawing
the outline.stroke
in interface Shapable
fi.utu.cs.appearance.Shapable
Shapable.isDrawn()
,
Stroke
public java.awt.Color color()
Shapable
Color
object that is used for drawing
the outline.color
in interface Shapable
fi.utu.cs.appearance.Shapable
Shapable.isDrawn()
,
Color
public boolean isFilled()
Shapable
isFilled
in interface Shapable
fi.utu.cs.appearance.Shapable
Shapable.paint()
public java.awt.Paint paint()
Shapable
Paint
object that is used for filling
the shape.paint
in interface Shapable
fi.utu.cs.appearance.Shapable
Shapable.isFilled()
,
Paint
public java.lang.String toString()
Body
toString
in class Body
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |