scg/ch09/EndOfGame

From FANG

Jump to: navigation, search

01 package scg.ch09;
02 
03 import fang2.core.Game;
04 import fang2.sprites.StringSprite;
05 
06 /**
07  * The "game" is really just a level of the main game. It is
08  * constructed to display a message on how well the player did (it is
09  * initialized with the player's score) and then the setup creates a
10  * centered end-of-game message.
11  */
12 public class EndOfGame
13   extends Game {
14   /** the score provided to the constructor */
15   private final int initialScore;
16 
17   /**
18    * Construct a new EndOfGame level. Requires the score to display for
19    * the player.
20    *
21    @param  initialScore  the player's score
22    */
23   public EndOfGame(int initialScore{
24     this.initialScore = initialScore;
25   }
26 
27   /**
28    * Setup the display information on the screen.
29    */
30   @Override
31   public void setup() {
32     setScore(initialScore);
33     StringSprite announcement = new StringSprite();
34     announcement.setText("GAME OVER\nFinal Score: " + getScore());
35     announcement.setScale(1.0);
36     announcement.setLocation(0.50.5);
37     addSprite(announcement);
38   }
39 }
40 
41 //Uploaded on Mon Mar 29 21:39:39 EDT 2010


Download/View scg/ch09/EndOfGame.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter

Games
Games