arcade/ArcadeLevel

From ggc

Jump to: navigation, search

01 package arcade;
02 
03 import fang.GameLevel;
04 
05 /**
06  * This class represents a single game that could
07  * be played as part of an overall arcade.  Make
08  * your class extend ArcadeLevel instead of GameLoop,
09  * and change the name of startGame to startLevel
10  * and your game can be included in the arcade by
11  * adding your game to ArcadeGame.  ArcadeLevels follow
12  * a heirarchical structure.
13  @author Jam Jenkins
14  *
15  */
16 public abstract class ArcadeLevel
17       extends GameLevel
18       implements Comparable
19 {
20   /**the level that the game should go to
21    * after finishing this level.*/
22   private ArcadeLevel parent;
23 
24   /**
25    * sets the level that the game should
26    * go to after this level finishes.
27    * Most classes should not need to
28    * call this method - it is primarily
29    * called from the ArcadeGame.
30    @param p the next level to go to
31    */
32   public void setParent(ArcadeLevel p)
33   {
34     parent=p;
35   }
36 
37   /**
38    * gets which level the game should go
39    * to after this one finishes
40    @return the next level after the current
41    * level ends
42    */
43   public ArcadeLevel getParent()
44   {
45     return parent;
46   }
47 
48   @Override
49   public void finishLevel()
50   {
51     if(parent!=this)
52       setNextLevel(parent);
53     super.finishLevel();
54   }
55 
56   /**
57    this method simply returns the fully
58    * qualified name of the class.  Most
59    * games should override this method and
60    * provide their own unique name.
61    @return the name of the game used
62    * in the display
63    */
64   public String toString()
65   {
66     System.out.println("returning "+getClass().getCanonicalName());
67     return getClass().getCanonicalName();
68   }
69 
70 
71   @Override
72   /**
73    * classes extending ArcadeLevel must implement
74    this method.
75    */
76   public abstract void advanceFrame(double timePassed);
77 
78   @Override
79   /**
80    * classes extending ArcadeLevel must implement
81    this method.
82    */
83   public abstract void startLevel();
84 
85   /**
86    * calls the compareTo method on the game names.
87    * This is used so that games can be arranged in
88    * alphabetical order.
89    */
90   public int compareTo(Object o)
91   {
92     System.out.println("o is "+o);
93     System.out.println("toString is "+toString());
94     return toString().compareTo(o.toString());
95   }
96 }
97 


Download/View arcade/ArcadeLevel.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