Class EnemyShips
[ Source
| Index
| Back to Nelzan ]
- public class EnemyShips
- extends Object
EnemyShips - controls enemy actions, movement, and painting.
This class downloads, stores, handles, and draws all information
dealing with enemy ships that fly around.
-
comp
-
-
damage
-
-
dataFile
-
-
dir
-
-
fire
-
-
fireHeight
-
-
fireX
-
-
fireY
-
-
height
-
-
imgDown
-
-
imgFire
-
-
imgNorm
-
-
imgUp
-
-
length
-
-
move
-
-
myImages
-
-
r
- For Generating Random Numbers
-
shields
-
-
step
-
-
subStep
-
-
type
-
-
width
-
-
x
-
-
y
-
-
EnemyShips(Image[], int, Nelzan)
- Defines a new class of EnemyShips to be manipulated.
-
abs(int)
- Returns the distance from zero.
-
buildNew(int)
- Build arrays of the correct length so data can be placed inside them.
-
checkDamage(int)
- This function checks to see if a ship or its fired weapon are in
contact with the player.
-
getFile(int)
- Download the level file and loads it into Arrays.
-
getImage(int)
- This function determins if the ship's normal, up, or down image should
be shown.
-
levelOver()
- A Quick Check to see if the level is over.
-
move(int)
- Moves the player based on it's movement string.
-
paint(Graphics)
- Paints all the enemies on the screen.
-
toInt(String)
- Converts a String to an int;
-
update()
- Updates enemy location, fire location, and handles collision logic.
type
private int type[]
width
private int width[]
height
private int height[]
shields
private int shields[]
damage
private int damage[]
x
private int x[]
y
private int y[]
move
private String move[]
fire
private String fire[]
imgNorm
private int imgNorm[]
imgFire
private int imgFire[]
imgUp
private int imgUp[]
imgDown
private int imgDown[]
step
private int step[]
subStep
private int subStep[]
fireX
private int fireX[]
fireY
private int fireY[]
fireHeight
private int fireHeight[]
myImages
private Image myImages[]
comp
private Nelzan comp
dataFile
private URL dataFile
length
private int length
dir
private int dir
r
Random r
- For Generating Random Numbers
EnemyShips
EnemyShips(Image img[],
int level,
Nelzan c)
- Defines a new class of EnemyShips to be manipulated. Will download
information from the correct level and store it into private arrays.
- Parameters:
- img - Images of the ships
- level - The current player's Level
- c - Instance of Nelzan, for callbacks.
update
public void update()
- Updates enemy location, fire location, and handles collision logic.
This function is the brains of all Enemy ships. This updates their
location and causes them to move, updates their fire location, and
it makes sure the ship or it's weapon is not in contact with the player.
levelOver
public boolean levelOver()
- A Quick Check to see if the level is over.
- Returns:
-
true if all members are destoryed,
fasle otherwise.
paint
public void paint(Graphics g)
- Paints all the enemies on the screen. There is no Z-ordering done in
this function, ships are drawn in the order they presented in the
array.
- Parameters:
- g - The Graphics to draw to.
checkDamage
private void checkDamage(int i)
- This function checks to see if a ship or its fired weapon are in
contact with the player. It also check to see if the players weapon
is hitting the ship via a callback. If the ship shiels are less than
or equal to zero the ship is destoryed.
- Parameters:
- i - Array index to check at.
getImage
private int getImage(int i)
- This function determins if the ship's normal, up, or down image should
be shown.
- Parameters:
- i - Array index to get Image at.
- Returns:
-
int with the location of the image
to be shown.
move
private void move(int i)
- Moves the player based on it's movement string.
- Parameters:
- i - Array index to move.
getFile
private void getFile(int i)
- Download the level file and loads it into Arrays.
- Parameters:
- i - Level to be loaded
buildNew
private void buildNew(int i)
- Build arrays of the correct length so data can be placed inside them.
- Parameters:
- i - Length arrays need to be.
toInt
private int toInt(String s)
- Converts a String to an int;
- Parameters:
- s - The String to be converted
- Returns:
- an
int value from s
abs
private int abs(int i)
- Returns the distance from zero.
- Parameters:
- i - The number to check.
- Returns:
- s an
int of the distance from zero.
|