LotsOfShapes

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 LotsOfShapes extends GameLoop
10 {
11   /**an oval*/
12   private Sprite[] oval;
13 
14   /**sets up the game*/
15   public void startGame()
16   {
17     oval=new Sprite[100];
18     makeSprites();
19     addSprites();
20   }
21 
22   /**makes the sprites*/
23   private void makeSprites()
24   {
25     for(int i=0; i<oval.length; i++)
26     {
27       oval[i]=new PolygonSprite(random.nextInt(5)+3);
28       oval[i].setScale(random.nextDouble());
29       oval[i].setLocation(random.nextDouble(), random.nextDouble());
30       Color color=new Color(random.nextFloat(), random.nextFloat(), random.nextFloat());
31       oval[i].setColor(color);
32     }
33   }
34 
35   /**adds the sprites to the screen*/
36   private void addSprites()
37   {
38     for(int i=0; i<oval.length; i++)
39     {
40       canvas.addSprite(oval);
41     }
42   }
43 
44   public void advanceFrame(double timePassed)
45   {
46     Point2D.Double click=getPlayer().getMouse().getClickLocation();
47     if(click!=null)
48     {
49       for(int i=0; i<oval.length; i++)
50       {
51         if(oval[i].intersects(click))
52         {
53           canvas.removeSprite(oval[i]);
54         }
55       }
56     }
57   }
58 
59 }


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