Nick/NickArcadeLauncher

From ggc

Jump to: navigation, search

01 package Nick;
02 
03 import java.awt.Color;
04 import java.awt.event.KeyEvent;
05 import arcade.*;
06 import fang.*;
07 
08 /**
09  * This class simply launches the ArcadeGame.
10  @author Nick McKee 
11  */
12 public class NickArcadeLauncher extends GameLoop
13 {
14   private ArcadeGame topLevel;
15 
16   /**
17    * sets the level at which to start
18    */
19   public void startGame()
20   {
21     topLevel=new NickArcade();
22     topLevel.setName("Nick's Arcade");
23     setNextLevel(topLevel);
24 
25     StringSprite toFinish=new StringSprite("Press ESC\nto end game");
26     toFinish.rightJustify();
27     toFinish.bottomJustify();
28     toFinish.setScale(0.2);
29     toFinish.setLocation(0.980.98);
30     toFinish.setColor(new Color(255255064));
31     canvas.addSprite(toFinish);
32     topLevel.persist(toFinish);
33   }
34 
35   /**
36    * enables the Escape key to finish the level at any time
37    */
38   public void advanceFrame(double timeElapsed)
39   {
40     if(getPlayer().getKeyboard().getLastKey()==KeyEvent.VK_ESCAPE)
41       finishLevel();
42     if(getLevelNumber()==0)
43       setNextLevel(topLevel);
44   }
45 
46   /**
47    * runs the game as an application
48    @param args not used
49    */
50   public static void main(String[] args)
51   {
52     new ArcadeLauncher().runAsApplication();
53   }
54 }


Download/View Nick/NickArcadeLauncher.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