examples/levelSelect/LevelSelect

From FANG

Jump to: navigation, search

01 package examples.levelSelect;
02 //start auto-imports
03 import javax.swing.*;
04 //end auto-imports
05 
06 import fang2.attributes.*;
07 import fang2.core.*;
08 import fang2.sprites.*;
09 import fang2.transformers.*;
10 import java.awt.geom.*;
11 
12 /**
13  * This class selects the level to
14  * move to.
15  @author Alex Park
16  @author modified by Jam when the
17  * FANG Engine was updated
18  */
19 public class LevelSelect
20       extends Game
21 {
22   /**Sprite to click to go to level 1*/
23   private StringSprite level1;
24   /**Sprite to click to go to level 2*/
25   private StringSprite level2;
26 
27   /**
28    * makes and adds the sprites.
29    */
30   public void setup()
31   {
32     makeSprites();
33     addSprites();
34   }
35 
36   /**
37    *Adds sprites to the screen 
38    */
39   public void addSprites()
40   {
41     addSprite(level1);
42     addSprite(level2);
43   }
44 
45   /**
46    * Makes the sprites
47    */
48   public void makeSprites()
49   {
50     level1 = new StringSprite("Click to go to Level 1");
51     level1.setLocation(0.50.25);
52     level1.setScale(0.85);
53     level1.centerJustify();
54 
55     level2 = new StringSprite("Click to go to Level 2");
56     level2.setLocation(0.50.75);
57     level2.setScale(0.85);
58     level2.centerJustify();
59   }
60   /**
61    * goes to the next level when clicked
62    */
63   public void advance()
64   {
65     handleClick();
66   }
67 
68   /**
69    * Sets the variable levelNumber to a value
70    * when the screen is clicked
71    */
72   public void handleClick()
73   {
74     Location2D mouse = getClick2D();
75     if (mouse != null)
76     {
77       if(mouse.y >= && mouse.y <= 0.5)
78       {
79         addGame(new Level1("You are in Level 1\nClick to go back"));
80         finishGame();
81       }
82       else if(mouse.y <= && mouse.y >= 0.5)
83       {
84         addGame(new Level1("You are in Level 2\nClick to go back"));
85         finishGame();
86       }
87     }
88   }
89 }
90 
91 //Uploaded on Sat Sep 19 13:58:07 EDT 2009


Download/View examples/levelSelect/LevelSelect.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