ClickEvenOrOddExample

From ggc

Jump to: navigation, search

01 import fang.*;
02 import java.awt.*;
03 import java.awt.geom.*;
04 
05 /**
06  * All about my game here.
07  @author Jam Jenkins
08  */
09 public class ClickEvenOrOddExample extends GameLoop
10 {
11   private int clickCount;
12 
13   /**sets up the game*/
14   public void startGame()
15   {
16     clickCount=0;
17   }
18 
19   private void doStage1Interaction()
20   {
21     PolygonSprite poly=new PolygonSprite(3);
22     Point2D.Double location=getPlayer().getMouse().getClickLocation();
23     poly.setLocation(location);
24     poly.setScale(0.2);
25     canvas.addSprite(poly);
26   }
27 
28   private void doStage2Interaction()
29   {
30     PolygonSprite poly=new PolygonSprite(4);
31     Point2D.Double location=getPlayer().getMouse().getClickLocation();
32     poly.setLocation(location);
33     poly.setScale(0.2);
34     canvas.addSprite(poly);
35   }
36 
37   /**handle input and game events*/
38   public void advanceFrame(double timePassed)
39   {
40     if(getPlayer().getMouse().getClickLocation()!=null)
41     {
42       clickCount=clickCount+1;
43       if(clickCount%2==0)
44       {
45         doStage1Interaction();
46       }
47       else if(clickCount%2==1)
48       {
49         doStage2Interaction();
50       }
51     }
52   }
53 }


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