SpaceInvaders
Class Score

java.lang.Object
  |
  +--SpaceInvaders.Score

public class Score
extends java.lang.Object

Maintains and displays the game score.

Version:
1.0, 30 October 2001
Author:
Susan B. Cavanaugh

Field Summary
private  int oldScore
          the previous game score
private  Point screenPos
          screen position of score display
private  int theScore
          the current game's score
 
Constructor Summary
Score()
          Default constructor initializes score to zero and sets the screen position of score display to (10, 10).
Score(int startingScore, Point onScreen)
          Accepts score and screen position.
 
Method Summary
 void draw(java.awt.Graphics g)
          Draws the score on the screen.
 void increment()
          Increments the score by 1, the default increment.
 void increment(int i)
          Increments the score by a specified amount.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

theScore

private int theScore
the current game's score

oldScore

private int oldScore
the previous game score

screenPos

private Point screenPos
screen position of score display
Constructor Detail

Score

public Score()
Default constructor initializes score to zero and sets the screen position of score display to (10, 10).

Score

public Score(int startingScore,
             Point onScreen)
Accepts score and screen position.
Parameters:
startingScore - the score setting
onScreen - the screen position of score display
Method Detail

draw

public void draw(java.awt.Graphics g)
Draws the score on the screen. To eliminate flicker, the old score is overwritten in background color, then the new one is drawn in white.
Parameters:
g - the Graphics context

increment

public void increment()
Increments the score by 1, the default increment.

increment

public void increment(int i)
Increments the score by a specified amount.
Parameters:
i - score increment