objects
Class Ship

java.lang.Object
  |
  +--objects.DrawableGameObject
        |
        +--objects.Ship

public final class Ship
extends DrawableGameObject

A ship. Note that most of the information you need may be available in the Player object of the owner of this ship.

If you write a user defined client, you should not try change this object by calling any of it's setter methods, as it will make your view of the game different from all the other players' views.

Also note that for clients, not all getter methods return usable results, as the server doesn't send everything across. The following information is, however, updated and usable for this class:

Author:
Sverre H. Huseby <shh@thathost.com>
See Also:
Player

Field Summary
 
Fields inherited from class objects.DrawableGameObject
bounds, dir, loc
 
Constructor Summary
Ship(Player owner)
          Constructs a new ship with the given owner.
 
Method Summary
 void draw(java.awt.Graphics g)
          Draws the object in the given graphic context.
 java.awt.Color getColor()
          Returns the main color used for drawing this object.
 int getPhaserOffset()
          Returns the distance from the center of the ship to the cannon.
 boolean isHitBy(int x, int y)
          Checks if a point is within this ship.
 boolean isHitBy(java.awt.Point p)
          Checks if a point is within this ship.
 void setColor(java.awt.Color col)
          Sets the main color used when drawing this object.
protected  void updateBounds()
           
 
Methods inherited from class objects.DrawableGameObject
getBounds, getDirection, getDirectionAsShort, getId, getLocation, setDirection, setDirectionFromShort, setId, setLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ship

public Ship(Player owner)
Constructs a new ship with the given owner. Also updates the bounding box of the object.

Parameters:
owner - the player who controls this ship.
Method Detail

updateBounds

protected final void updateBounds()
Overrides:
updateBounds in class DrawableGameObject

setColor

public final void setColor(java.awt.Color col)
Sets the main color used when drawing this object.

Parameters:
col - the color.

getColor

public final java.awt.Color getColor()
Returns the main color used for drawing this object.

Returns:
the color.

getPhaserOffset

public final int getPhaserOffset()
Returns the distance from the center of the ship to the cannon. Used by the server when creating phasers and bombs fired by this ship.

Returns:
the offset in pixels.

isHitBy

public final boolean isHitBy(int x,
                             int y)
Checks if a point is within this ship.

Parameters:
x - the x-coordinate.
y - the y-coordinate.
Returns:
true if the point is considered to be inside the ship, false otherwise.

isHitBy

public final boolean isHitBy(java.awt.Point p)
Checks if a point is within this ship.

Parameters:
p - the point.
Returns:
true if the point is considered to be inside the ship, false otherwise.

draw

public final void draw(java.awt.Graphics g)
Description copied from class: DrawableGameObject
Draws the object in the given graphic context. The graphic context controls an Image with the size of the entire world, so the drawing routine doesn't need to displace it's coordinates.

Specified by:
draw in class DrawableGameObject
Parameters:
g - the graphic context.
See Also:
DrawableGameObject