SpaceInvaders
Class Star

java.lang.Object
  |
  +--SpaceInvaders.Point
        |
        +--SpaceInvaders.Pixel
              |
              +--SpaceInvaders.Star

public class Star
extends Pixel

Encapsulates star behavior.

Version:
1.1, 10 November 2001
Author:
Susan B. Cavanaugh

Field Summary
private  Point prevPos
          previous screen position
 
Fields inherited from class SpaceInvaders.Pixel
c
 
Fields inherited from class SpaceInvaders.Point
x, y
 
Constructor Summary
Star(Point p, java.awt.Color c)
          Accepts a star's screen position and color.
 
Method Summary
 void draw(java.awt.Graphics g)
          Draws the star on the screen.
 int getX()
          Gets x coordinate.
 int getY()
          Gets y coordinate.
 void move()
          Advances star straight downward 1 pixel per move, restarting the screen position to the top of the screen when the star moves off the bottom of the screen.
 
Methods inherited from class SpaceInvaders.Pixel
getColor, setColor
 
Methods inherited from class SpaceInvaders.Point
setX, setXY, setY
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

prevPos

private Point prevPos
previous screen position
Constructor Detail

Star

public Star(Point p,
            java.awt.Color c)
Accepts a star's screen position and color.
Parameters:
p - screen position
c - the RGB color
Method Detail

getX

public int getX()
Gets x coordinate.
Overrides:
getX in class Point
Returns:
x coordinate of screen position.

getY

public int getY()
Gets y coordinate.
Overrides:
getY in class Point
Returns:
y coordinate of screen position.

draw

public void draw(java.awt.Graphics g)
Draws the star on the screen.
Parameters:
g - Graphics context to draw in.

move

public void move()
Advances star straight downward 1 pixel per move, restarting the screen position to the top of the screen when the star moves off the bottom of the screen.