JacobOlson/Feb21

From ggc

Jump to: navigation, search

01 package JacobOlson;
02 import fang.*;
03 import java.awt.*;
04 import java.awt.geom.*;
05 
06 /**
07  * All about my game here.
08  @author Jolson
09  */
10 public class Feb21 extends GameLoop
11 {
12   /**an oval*/
13   private Sprite[] oval;
14 
15   /**sets up the game*/
16   public void startGame()
17   {
18     oval=new Sprite[100];
19     makeSprites();
20     addSprites();
21   }
22 
23   /**makes the sprites*/
24   private void makeSprites()
25   {
26     for(int i=0; i<oval.length; i++)
27     {
28       oval[i]=new PolygonSprite(random.nextInt(5)+3);
29       oval[i].setScale(random.nextDouble());
30       oval[i].setLocation(random.nextDouble(), random.nextDouble());
31       Color color=new Color(random.nextFloat(), random.nextFloat(), random.nextFloat());
32       oval[i].setColor(color);
33     }
34   }
35 
36   /**adds the sprites to the screen*/
37   private void addSprites()
38   {
39     for(int i=0; i<oval.length; i++)
40     {
41       canvas.addSprite(oval);
42     }
43   }
44 
45   public void advanceFrame(double timePassed)
46   {
47     Point2D.Double click=getPlayer().getMouse().getClickLocation();
48     if(click!=null)
49     {
50       for(int i=0; i<oval.length; i++)
51       {
52         if(oval[i].intersects(click))
53         {
54           canvas.removeSprite(oval[i]);
55         }
56       }
57     }
58   }
59 
60 }


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