Class Gun

java.lang.Object
  extended by Gun
Direct Known Subclasses:
BulletBillGun, LaserGun

public class Gun
extends java.lang.Object

Gun: shoots (i. e. emits) missiles (like a Factory). Handles shooting timeouts. Can be put into a spaceship.


Field Summary
protected  double abs_speed
          Absolute value of the speed vector that's set to missiles.
protected  double angle
          Angle the missiles are launched with (to y axis, value in radians).
protected  int direction
          Direction the gun is facing.
protected  int dx
          X distance of launched bullets from spaceship center.
protected  int dy
           
static int initial_recovery
          Initial recovery time of this kind of gun.
protected  int level
          Level of the gun (and thus of the missiles).
protected  int recovery
          The number to which timer is set after a bullet has been launched.
protected  int side
          Side the gun (and so the missiles) is on.
protected  Vector speed
          Speed the missiles are set to when launched.
protected  int timer
          This variable determines how many turns the gun has to wait before it may emit another bullet.
 
Constructor Summary
Gun()
           
Gun(double the_abs_speed, double the_angle)
           
Gun(Vector the_speed)
           
 
Method Summary
 Gun copy_gun()
          Return an exact copy of this gun.
 int get_dx()
           
 int get_dy()
           
protected  Missile get_missile()
           
 double getAbsSpeed()
           
 double getAngle()
           
static int getInitialRecovery()
           
 int getLevel()
           
 int getRecovery()
           
 int getSide()
           
 int getTimer()
           
protected  void init()
           
 Missile missile()
          Emit a new bullet or null if not ready yet.
 void set_dx(int new_dx)
           
 void set_dy(int new_dy)
           
static void setInitialRecovery(int the_recovery)
           
 void setLevel(int the_level)
           
 void setRecovery(int the_recovery)
           
 void setSide(int new_side)
           
 void setSpeed(double the_abs_speed, double the_angle)
           
 void setSpeed(Vector the_speed)
           
 void setTimer(int timer_value)
           
 void tick()
          Send a tick to the gun every time act() is called in the containing spaceship.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timer

protected int timer
This variable determines how many turns the gun has to wait before it may emit another bullet. It is counted down; when it reaches 0, we can shoot. Otherwise, the gun will just shoot out thin air (i. e., a null pointer) when asked for a missile.

See Also:
missile()

recovery

protected int recovery
The number to which timer is set after a bullet has been launched. (I. e., the number of turns that will pass between two missiles.


speed

protected Vector speed
Speed the missiles are set to when launched.


side

protected int side
Side the gun (and so the missiles) is on.


level

protected int level
Level of the gun (and thus of the missiles).


dx

protected int dx
X distance of launched bullets from spaceship center.


dy

protected int dy
See Also:
dx

abs_speed

protected double abs_speed
Absolute value of the speed vector that's set to missiles.


angle

protected double angle
Angle the missiles are launched with (to y axis, value in radians).


direction

protected int direction
Direction the gun is facing. Allows for easier dy calculation in subclasses.

See Also:
dy

initial_recovery

public static int initial_recovery
Initial recovery time of this kind of gun. (Without alteration by FasterGuns, that is.)

Constructor Detail

Gun

public Gun(double the_abs_speed,
           double the_angle)

Gun

public Gun(Vector the_speed)

Gun

public Gun()
Method Detail

copy_gun

public Gun copy_gun()
Return an exact copy of this gun. Used especially in the MoreGuns powerup. TODO: make this more dynamic.

See Also:
MoreGuns

init

protected void init()

setSpeed

public void setSpeed(Vector the_speed)

setSpeed

public void setSpeed(double the_abs_speed,
                     double the_angle)

tick

public void tick()
Send a tick to the gun every time act() is called in the containing spaceship. This is used to handle the internal firing timer.


get_missile

protected Missile get_missile()

missile

public Missile missile()
Emit a new bullet or null if not ready yet.

Returns:
the bullet or null

get_dx

public int get_dx()

get_dy

public int get_dy()

set_dx

public void set_dx(int new_dx)

set_dy

public void set_dy(int new_dy)

getSide

public int getSide()

setSide

public void setSide(int new_side)

getTimer

public int getTimer()

setTimer

public void setTimer(int timer_value)

getLevel

public int getLevel()

setLevel

public void setLevel(int the_level)

getRecovery

public int getRecovery()

setRecovery

public void setRecovery(int the_recovery)

getAbsSpeed

public double getAbsSpeed()

getAngle

public double getAngle()

getInitialRecovery

public static int getInitialRecovery()

setInitialRecovery

public static void setInitialRecovery(int the_recovery)