jam/GravityTrackerTest

From ggc

Jump to: navigation, search

01 package jam;
02 
03 import wiki.Wiki;
04 import fang.*;
05 import java.awt.*;
06 import java.awt.geom.*;
07 
08 /**
09  * All about my game here.
10  @author Jam Jenkins
11  */
12 public class GravityTrackerTest extends GameLoop
13 {
14   /**an oval*/
15   private Sprite oval;
16   private GravityTracker tracker;
17   /**sets up the game*/
18   public void startGame()
19   {
20     makeSprites();
21     addSprites();
22   }
23 
24   /**makes the sprites*/
25   private void makeSprites()
26   {
27     oval=new OvalSprite(21);
28     oval.setScale(0.75);
29     oval.setLocation(0.50.5);
30     tracker=new GravityTracker(0, -0.25);
31     oval.setTracker(tracker);
32   }
33 
34   /**adds the sprites to the screen*/
35   private void addSprites()
36   {
37     canvas.addSprite(oval);
38   }
39 
40   /**handle input and game events*/
41   public void advanceFrame(double timePassed)
42   {
43     if(oval.getLocation().y>0.8)
44     {
45       tracker.setVelocity(new Point2D.Double(0, -0.25));
46     }
47     if(getPlayer().getMouse().getClickLocation()!=null)
48     {
49       tracker.setGravityAmount(0.2);
50     }
51   }
52 }


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