jam/DotsDisappear

From ggc

Jump to: navigation, search

001 package jam;
002 
003 import wiki.Wiki;
004 import java.util.*;
005 import fang.*;
006 import java.awt.*;
007 import java.awt.geom.*;
008 
009 /**
010  * All about my game here.
011  @author Jam Jenkins
012  */
013 public class DotsDisappear extends GameLoop
014 {
015   private ArrayList<Sprite> oval;
016 
017   public void startGame()
018   {
019     oval=new ArrayList<Sprite>();
020     //oval=new OvalSprite(1, 1);
021     //oval.setScale(0.75);
022     //oval.setLocation(0.5, 0.5);
023     //canvas.addSprite(oval);
024     makePlus();
025   }
026 
027   public void advanceFrame(double timePassed)
028   {
029     Point2D.Double click=getPlayer().getMouse().getClickLocation();
030     for(Sprite one: oval)
031     {
032       if(click!=null && one.intersects(click))
033         canvas.removeSprite(one);
034     }
035   }
036 
037   private void makePlus()
038   {
039     makeDotsAcross(0.150);
040     makeDotsAcross(0.350);
041     makeDotsAcross(0.550);
042     makeDotsAcross(0.750);
043     makeDotsAcross(0.950);
044     //makeDotsAcross0();
045     //makeDotsAcross1();
046     //makeDotsAcross2();
047     //makeDotsDown();
048   }
049 
050   private void makeDotsAcross(double y, int numDots)
051   {
052     for(int i=0; i<numDots; i++)
053     {
054       double x=(i+0.5)/numDots;
055       OvalSprite dot=new OvalSprite(11);
056       dot.setScale((1.0/numDots)/2);
057       dot.setLocation(x, y);
058       canvas.addSprite(dot);
059       oval.add(dot);
060     }
061   }
062 
063   private void makeDotsAcross0()
064   {
065     int numDots=5;
066     for(int i=0; i<numDots; i++)
067     {
068       double x=(i+0.5)/numDots;
069       double y=0.4;
070       OvalSprite dot=new OvalSprite(11);
071       dot.setScale((1.0/numDots)/2);
072       dot.setLocation(x, y);
073       canvas.addSprite(dot);
074     }
075   }
076   private void makeDotsAcross1()
077   {
078     int numDots=5;
079     for(int i=0; i<numDots; i++)
080     {
081       double x=(i+0.5)/numDots;
082       double y=0.5;
083       OvalSprite dot=new OvalSprite(11);
084       dot.setScale((1.0/numDots)/2);
085       dot.setLocation(x, y);
086       canvas.addSprite(dot);
087     }
088   }
089   private void makeDotsAcross2()
090   {
091     int numDots=5;
092     for(int i=0; i<numDots; i++)
093     {
094       double x=(i+0.5)/numDots;
095       double y=0.6;
096       OvalSprite dot=new OvalSprite(11);
097       dot.setScale((1.0/numDots)/2);
098       dot.setLocation(x, y);
099       canvas.addSprite(dot);
100     }
101   }
102 
103   private void makeDotsDown()
104   {
105     int numDots=5;
106     for(int i=0; i<numDots; i++)
107     {
108       double x=0.5;
109       double y=(i+0.5)/numDots;
110       OvalSprite dot=new OvalSprite(11);
111       dot.setScale((1.0/numDots)/2);
112       dot.setLocation(x, y);
113       canvas.addSprite(dot);
114     }
115   }
116 }


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