se.liu.student.kimgr905.tilegame.sprites
Class Ship

java.lang.Object
  extended by se.liu.student.kimgr905.tilegame.sprites.Sprite
      extended by se.liu.student.kimgr905.tilegame.sprites.Ship
Direct Known Subclasses:
Biglazer, Boss, Drone, Minilazer, Player

public abstract class Ship
extends Sprite

A Ship is a Sprite that has three Animations and a certain amount of hitpoints.


Field Summary
private  boolean awake
           
private static int EXPLODE_TIME
           
private  Animation exploding
           
private  int hitPoints
           
private  Animation normal
           
private  long stateTime
           
 
Fields inherited from class se.liu.student.kimgr905.tilegame.sprites.Sprite
anim, STATE_DEAD, STATE_EXPLODING, STATE_NORMAL, STATE_SHOOTING
 
Constructor Summary
Ship(Animation normal, Animation exploding)
          Creates a ship with the specified animation.
 
Method Summary
 void changePath()
          Changes the ships path, should be overwritten by ships that need to change path by certain patterns.
 void changePath(Player player)
          Same as changePath(), but also takes a Player argument for ships that follow the player.
 java.lang.Object clone()
          Clone is used to create a deepcopy of the ship.
 int getHitPoints()
          Return current hit points of the ship.
 void hit()
          When the ship gets hit it loses a hitpoint.
(package private)  boolean isAwake()
           
(package private)  void setHitPoints(int hitPoints)
           
 void setState(int state)
          Sets the state of the ship.
 void shoot()
          Sets shooting variables, should be overwritten by ships that shoot.
 void update(long elapsedTime)
          Updates the animaton for this ship.
 void wakeUp()
          Awakens the ship.
 
Methods inherited from class se.liu.student.kimgr905.tilegame.sprites.Sprite
getHeight, getImage, getState, getVelocityX, getVelocityY, getWidth, getX, getY, isAlive, setVelocityX, setVelocityY, setX, setY
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXPLODE_TIME

private static final int EXPLODE_TIME
See Also:
Constant Field Values

awake

private boolean awake

hitPoints

private int hitPoints

stateTime

private long stateTime

normal

private final Animation normal

exploding

private final Animation exploding
Constructor Detail

Ship

public Ship(Animation normal,
            Animation exploding)
Creates a ship with the specified animation.

Parameters:
normal - normal animation
exploding - exploding animation
Method Detail

clone

public final java.lang.Object clone()
Clone is used to create a deepcopy of the ship.

Overrides:
clone in class Sprite
Returns:
a cloned object of the correct subclass

update

public final void update(long elapsedTime)
Updates the animaton for this ship.

Overrides:
update in class Sprite
Parameters:
elapsedTime - the time elapsed since the last update in ms

setState

public final void setState(int state)
Sets the state of the ship.

Overrides:
setState in class Sprite
Parameters:
state - the state of the ship

wakeUp

public void wakeUp()
Awakens the ship.


isAwake

final boolean isAwake()

getHitPoints

public final int getHitPoints()
Return current hit points of the ship.

Returns:
current hitPoints

setHitPoints

final void setHitPoints(int hitPoints)

hit

public void hit()
When the ship gets hit it loses a hitpoint.


shoot

public void shoot()
Sets shooting variables, should be overwritten by ships that shoot.


changePath

public void changePath()
Changes the ships path, should be overwritten by ships that need to change path by certain patterns.


changePath

public void changePath(Player player)
Same as changePath(), but also takes a Player argument for ships that follow the player.

Parameters:
player - the player