|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--SpaceInvaders.Ship
Encapsulates the spaceship functionality.
| Field Summary | |
private static int |
height
spaceship image height in pixels |
private Point |
prevPos
previous position of spaceship |
private Point |
screenPos
position of spaceship on the screen |
private static int |
width
spaceship image width in pixels |
| Constructor Summary | |
Ship()
Default constructor initializing spaceship's image position to (300, 430). |
|
Ship(Point p)
Accepts screen coordinates for spaceship's image position. |
|
| Method Summary | |
void |
draw(java.awt.Graphics g)
Overwrites the previous move and leaves the actual spaceship image handling and drawing to the applet's paint method. |
static int |
getHeight()
Gets the height of a spaceship image. |
Point |
getPosition()
Gets the screen position. |
static int |
getWidth()
Gets the width of a spaceship image. |
void |
move(boolean moveRight)
Moves spaceship either right or left. |
static void |
setHeight(int h)
Sets the height of a spaceship image. |
void |
setPosition(Point p)
Sets the screen position of this spaceship image. |
static void |
setWidth(int w)
Sets the width of a spaceship image. |
Laser |
shoot()
Shoots a yellow laser from top of spaceship. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private static int width
private static int height
private Point screenPos
private Point prevPos
| Constructor Detail |
public Ship()
public Ship(Point p)
p - screen location| Method Detail |
public static void setWidth(int w)
w - width in pixelspublic static int getWidth()
public static void setHeight(int h)
h - height in pixelspublic static int getHeight()
public void setPosition(Point p)
p - screen positionpublic Point getPosition()
public void draw(java.awt.Graphics g)
g - the graphics contextpublic void move(boolean moveRight)
moveRight - move spaceship right flag; true for right movepublic Laser shoot()
Laser object.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||