MattCrauswell/InteractiveArt

From ggc

Jump to: navigation, search

001 package MattCrauswell;
002 
003 import wiki.Wiki;
004 import fang.*;
005 import java.awt.*;
006 import java.awt.geom.*;
007 import Beta.OutlineTracker;
008 
009 /**
010  * All about my game here.
011  @author Mcrauswe
012  */
013 public class InteractiveArt extends GameLoop
014 {
015 
016   /**Plays wonderful sound, if game doesn't run, please remove above line for music file. It has been making it not run at some times*/
017   private Sprite title, name;
018   private Sprite dot;
019   private Sprite tri;
020   private Sprite moving;
021   /**For the shapes*/
022   private OutlineTracker tracker;
023   /**To move sprite*/
024   private Sprite square;
025   /**For another shape*/
026   private ProjectileTracker track;
027   /**For the alarm*/
028 
029 
030   public void startGame()
031   {
032     makeSprites();
033     addSprites();
034     toggleAudible();
035   }
036 
037   private void makeSprites()
038   {
039     title=new StringSprite("Interactive Art");
040     title.setScale(.70);
041     title.setLocation(.5.12);
042     title.setColor(Color.RED);
043 
044     dot=new OvalSprite(11);
045     dot.setScale(.40);
046     dot.setLocation(.5.5);
047     dot.setColor(Color.GREEN);
048 
049     name=new StringSprite("Matt Crauswell");
050     name.setScale(.50);
051     name.setLocation(.30.97);
052     name.setColor(Color.BLUE);
053 
054     square=new PolygonSprite(4);
055     square.setScale(0.2);
056     square.setColor(Color.WHITE);
057     square.setLocation(0.50.5);
058 
059     moving=new PolygonSprite(5);
060     moving.setScale(0.2);
061     moving.setLocation(0.50.5);
062     canvas.addSprite(moving);
063 
064     moving=new PolygonSprite(5);
065     moving.setScale(0.2);
066     moving.setLocation(0.50.25);
067     canvas.addSprite(moving);
068 
069     tri=new PolygonSprite(3);
070     tri.setScale(0.1);
071     tri.setLocation(0.50.5);
072     tri.setColor(Color.RED);
073     /**All of the above are the attributes of the shapes that are made*/
074 
075     Sprite outline=new PolygonSprite(3);
076     outline.setScale(0.5);
077     outline.setLocation(0.50.5);
078     outline.setColor(Color.BLACK);
079     canvas.addSprite(outline);
080 
081     tracker=new OutlineTracker(outline, 0.5);
082     tri.setTracker(tracker);
083     tri.setLocation(tracker.getCurrentPoint());
084     /**This makes the tracker for its outline*/
085 
086     Point2D.Double direction=new Point2D.Double(0.00.0);
087     track=new ProjectileTracker(direction);
088     /**rotate 1/2 a revolution per second*/
089     track.setAngularVelocity(5);
090     square.setTracker(track);
091     /**This sets the square to rotate and how fast ti rotates as well*/
092 
093     setHelpText("Click the start button and help Mr. Triangle fit in his small teepee!");
094 
095   }
096 
097   private void addSprites()
098   {
099     canvas.addSprite(title, name);
100     canvas.addSprite(dot);
101     canvas.addSprite(tri);
102     canvas.addSprite(square);
103   }
104 
105   public void advanceFrame(double timePassed)
106   {
107     Point2D.Double click=getPlayer().getMouse().getClickLocation();
108     //did they click at all
109     if(click!=null)
110     {
111       if(tri.intersects(click))
112       {
113         canvas.removeSprite(tri);
114       }
115     }
116     if(getPlayer().getKeyboard().getLastKey()=='e')
117     {
118       dot.setColor(Color.BLUE);
119     }
120     if(getPlayer().getKeyboard().getLastKey()=='r')
121     {
122       dot.setColor(Color.RED);
123     }
124   }
125 
126 }


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