Class SpriteShip

java.lang.Object
  |
  +--Sprite
        |
        +--SpriteShip

class SpriteShip
extends Sprite

The player sprite, controlled by the keyboard.


Field Summary
(package private)  double ageDoneHyperjump
          A ship needs an ageDoneHyperjump as well as the Sprite ageDone, uses it for fading out of hyperjumps.
(package private)  double ageDoneShootwait
          Use the ageShootwait to time the wait between bullets shot.
(package private)  boolean down
          Key flag for down arrow key pressed.
(package private)  boolean firing
          Machine-gun firing key.
(package private) static boolean godmode
          Use this flag to mean that your ship never dies.
(package private)  boolean left
          Key flag for left arrow key pressed.
(package private) static int newShipScore
          Next score needed to get a new ship.
(package private)  boolean right
          Key flag for right arrow key pressed.
(package private) static int shipsLeft
          Number of ships left in game
(package private) static int TURN_STEP_THRESHOLD
          How many turn step updates before you shift into fast turning?
(package private)  int turnstepcount
          Track how many turn steps you've done on this key press.
(package private)  boolean up
          Key flag for up arrow key pressed.
 
Fields inherited from class Sprite
acceleration, active, age, ageDone, angle, angularAcceleration, bounce, edgecolor, fillcolor, fillflag, game, mass, maxspeed, ownerApp, position, positiontransform, radius, shape, shapetransform, soundplaying, velocity
 
Constructor Summary
SpriteShip(RealPixelConverter rtopc)
          Constructor sets colors, calls reset().
 
Method Summary
 void draw(java.awt.Graphics g, boolean detail)
          This fades the edge from black to white when you have a black fill, as is customary with a black background.
 void fire(RealPixelConverter rtopc)
          Make a sound and get a blank bullet slot or the oldest bullet slot and put a new bullet in there, aimed in your direction and starting at your location.
 void hyperjump()
          Randomize your location and give yourself an "immunity" for a few cycles.
 void keyPressed(int key)
          Process the arrow keys and spacebar.
 void keyReleased(int key)
          Process the arrow keys and spacebar.
 void loopsound(boolean onoff)
          Toggles the thrustersSound.
 void reset(RealPixelConverter rtopc)
          Puts the ship motionless in the middle of the screen.
 void stop()
          The stop method sets active to false and turns off the sound.
(package private)  double turnstep()
          A function that returns the slow or fast TURN_STEP depending on turnstepcount.
 void update(RealPixelConverter rtopc)
          The ship update method rotates the ship if left or right cursor key is down, Fires thrusters if up or down arrow key is down, calls advance and render, counts down the hyperspace counter if ship is in hyperspace.
 
Methods inherited from class Sprite
advance, explode, fixRadius, isColliding, isTouching, mass, radius, randomizeFillcolor, render, setFakeRadius, wrapandbounce
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

TURN_STEP_THRESHOLD

static final int TURN_STEP_THRESHOLD
How many turn step updates before you shift into fast turning?

turnstepcount

int turnstepcount
Track how many turn steps you've done on this key press.

newShipScore

static int newShipScore
Next score needed to get a new ship.

shipsLeft

static int shipsLeft
Number of ships left in game

left

boolean left
Key flag for left arrow key pressed.

right

boolean right
Key flag for right arrow key pressed.

up

boolean up
Key flag for up arrow key pressed.

down

boolean down
Key flag for down arrow key pressed.

firing

boolean firing
Machine-gun firing key.

ageDoneHyperjump

double ageDoneHyperjump
A ship needs an ageDoneHyperjump as well as the Sprite ageDone, uses it for fading out of hyperjumps.

ageDoneShootwait

double ageDoneShootwait
Use the ageShootwait to time the wait between bullets shot.

godmode

static boolean godmode
Use this flag to mean that your ship never dies.
Constructor Detail

SpriteShip

public SpriteShip(RealPixelConverter rtopc)
Constructor sets colors, calls reset().
Method Detail

turnstep

double turnstep()
A function that returns the slow or fast TURN_STEP depending on turnstepcount.

reset

public void reset(RealPixelConverter rtopc)
Puts the ship motionless in the middle of the screen.
Overrides:
reset in class Sprite

loopsound

public void loopsound(boolean onoff)
Toggles the thrustersSound.
Overrides:
loopsound in class Sprite

update

public void update(RealPixelConverter rtopc)
The ship update method rotates the ship if left or right cursor key is down, Fires thrusters if up or down arrow key is down, calls advance and render, counts down the hyperspace counter if ship is in hyperspace. If Ship is exploding, advance the countdown or create a new ship if it is done exploding. The new ship is added as though it were in hyperspace.(This gives the player time to move the ship if it is in imminent danger.) If that was the last ship, end the game.
Overrides:
update in class Sprite

stop

public void stop()
Description copied from class: Sprite
The stop method sets active to false and turns off the sound.
Overrides:
stop in class Sprite

fire

public void fire(RealPixelConverter rtopc)
Make a sound and get a blank bullet slot or the oldest bullet slot and put a new bullet in there, aimed in your direction and starting at your location.

hyperjump

public void hyperjump()
Randomize your location and give yourself an "immunity" for a few cycles.

keyPressed

public void keyPressed(int key)
Process the arrow keys and spacebar.

keyReleased

public void keyReleased(int key)
Process the arrow keys and spacebar.

draw

public void draw(java.awt.Graphics g,
                 boolean detail)
This fades the edge from black to white when you have a black fill, as is customary with a black background. It fades the edge from white to black otherwise.
Overrides:
draw in class Sprite