Class ManuallyControlledSpaceship

java.lang.Object
  extended by Actor
      extended by QuantumObject
          extended by Spaceship
              extended by ManuallyControlledSpaceship

public class ManuallyControlledSpaceship
extends Spaceship

A spaceship controlled by the player -- white or black.


Nested Class Summary
protected  class ManuallyControlledSpaceship.Keys
           
 
Field Summary
protected  boolean autofire
          If the spaceship should automatically fire whenever possible.
static int BASE_HP
           
static int COLLISION
          How many hitpoints a collision with another spaceship should cost.
protected  ManuallyControlledSpaceship.Keys keys
          Contains strings with the keys for all possible actions.
protected  boolean mayMoveUpAndDown
          Should the player be allowed to move the spaceship up and down?
static int MOVEMENT
          How many pixels the spaceship should move per turn when a movement key is pressed.
 
Fields inherited from class Spaceship
angled_guns, blink, blink_file, GUN_ANGLE, GUN_DISTANCE, guns, hitpoints, level, max_blink, max_hitpoints, n_guns, N_GUNS, side
 
Fields inherited from class QuantumObject
destroysOnNextTurn, disappear, mantissa, speed
 
Constructor Summary
ManuallyControlledSpaceship(int the_level)
           
 
Method Summary
 void act()
          Do quantum object duties, then check what the player wants the spaceship to do.
 void addHitpoints(int n_hitpoints)
           
 void beforeDestruction()
          Before destruction: tell world to announce the winner (which is the other side, if this is destroyed).
 boolean getMayMoveUpAndDown()
           
 int getSide()
           
 boolean hit(AIControlledSpaceship s)
          hit.
 void moveDown()
           
 void moveLeft()
           
 void moveRight()
           
 void moveUp()
           
 void removeHitpoints(int n_hitpoints)
           
 void setHitpoints(int n_hitpoints)
           
 void setMayMoveUpAndDown(boolean may)
           
 void setSide(int the_side)
           
protected  void setupImages()
          Sort-of abstract method available for overriddance [sic].
protected  void setupKeys()
          Set keys according to the side we're on.
 void updateHealth()
          Update the health bar in InvadersWorld.
 
Methods inherited from class Spaceship
addGun, angle, doBlink, fire, getBlinkFile, getHitpoints, getLevel, getMaxBlink, getMaxHitpoints, getNumberOfGuns, hit, removeGun, reorderGuns, setAngledGuns, setBlinkFile, setLevel, setMaxBlink, setMaxHitpoints
 
Methods inherited from class QuantumObject
getDestroysOnNextTurn, getSpeed, move, setDestroysOnNextTurn, setSpeed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_HP

public static final int BASE_HP
See Also:
Constant Field Values

COLLISION

public static final int COLLISION
How many hitpoints a collision with another spaceship should cost.

See Also:
Constant Field Values

MOVEMENT

public static final int MOVEMENT
How many pixels the spaceship should move per turn when a movement key is pressed.

See Also:
Constant Field Values

autofire

protected boolean autofire
If the spaceship should automatically fire whenever possible.


mayMoveUpAndDown

protected boolean mayMoveUpAndDown
Should the player be allowed to move the spaceship up and down?


keys

protected ManuallyControlledSpaceship.Keys keys
Contains strings with the keys for all possible actions.

See Also:
ManuallyControlledSpaceship.Keys, act()
Constructor Detail

ManuallyControlledSpaceship

public ManuallyControlledSpaceship(int the_level)
Method Detail

setupImages

protected void setupImages()
Description copied from class: Spaceship
Sort-of abstract method available for overriddance [sic]. Subclasses can implement this to set their sprite (back) to its default value. It's called whenever a reset to the default sprite is needed, e. g. after the blinking animation.

Overrides:
setupImages in class Spaceship
See Also:
Spaceship.doBlink()

setupKeys

protected void setupKeys()
Set keys according to the side we're on.


setSide

public void setSide(int the_side)
Overrides:
setSide in class Spaceship

getSide

public int getSide()
Overrides:
getSide in class Spaceship

setMayMoveUpAndDown

public void setMayMoveUpAndDown(boolean may)

getMayMoveUpAndDown

public boolean getMayMoveUpAndDown()

act

public void act()
Do quantum object duties, then check what the player wants the spaceship to do.

Overrides:
act in class Spaceship

moveLeft

public void moveLeft()

moveRight

public void moveRight()

moveUp

public void moveUp()

moveDown

public void moveDown()

updateHealth

public void updateHealth()
Update the health bar in InvadersWorld.

See Also:
InvadersWorld.setHealthBar(int side, int value)

addHitpoints

public void addHitpoints(int n_hitpoints)
Overrides:
addHitpoints in class Spaceship

removeHitpoints

public void removeHitpoints(int n_hitpoints)
Overrides:
removeHitpoints in class Spaceship

setHitpoints

public void setHitpoints(int n_hitpoints)
Overrides:
setHitpoints in class Spaceship

beforeDestruction

public void beforeDestruction()
Before destruction: tell world to announce the winner (which is the other side, if this is destroyed).

Overrides:
beforeDestruction in class Spaceship

hit

public boolean hit(AIControlledSpaceship s)
Description copied from class: QuantumObject
hit. Base method hit(Actor). Uses java.lang.reflect to dynamically find out which hit() method of the quantum object to invoke based on which actual class "actor" has. Dynamic dispatch comes true!

Overrides:
hit in class QuantumObject
Parameters:
s - The object we are interacting with
Returns:
boolean. True if this quantum object should survive, false otherwise.