Min Kim/InterArt

From ggc

Jump to: navigation, search

001 package Min_Kim;
002 
003 import fang.*;
004 import java.awt.*;
005 import java.awt.geom.*;
006 
007 /**
008  * All about my game.
009  @author My Name Here
010  */
011 public class InterArt extends Game
012 {
013   /** declaring image sprite*/
014   private ImageSprite face;
015   /** declaring spinner*/
016   private Spinner spinner1, spinner2;
017   /**ovalSprite making circles and ovals*/
018   private OvalSprite eye1, eye2, eye3, eye4, mouth1, mouth2, ball;
019   /**string*/
020   private StringSprite title, name;
021   /**rectangle*/
022   private RectangleSprite rec1, rec2, rec3;
023   /**outline which change sprite to an outline*/
024   private OutlineSprite boundary5;
025   /**projectile bounce*/
026   private ProjectileTransformer projectile;
027   /**clickcount stating its an integer and starts out with 0*/
028   private int clickcount;
029   /**sound1*/
030   private Sound sound1=new Sound("Mouse-doubleclick-01.wav");
031   /**sound2*/
032   private Sound sound2=new Sound("Hit-02.wav");
033   /**sets up the game*/
034   public void setup()
035   {
036     face();
037     eye1();
038     eye2();
039     eye3();
040     eye4();
041     rectangle();
042     rectangleSecond();
043     help();
044     boundary();
045     nameArt();
046     makeBall();
047     makeMouth();
048     moveRight();
049     moveLeft();
050 
051     projectile=new ProjectileTransformer(0.10.25);
052     ball.setTracker(projectile);
053   }
054   /**makes the help text when you click on the help button*/
055   private void help()
056   {
057     String helpText=
058         "Hello Welcome to Wackyface Interaction Art<br>"+
059         "press z to make the right eye ball move to the right<br>"+
060         "click on the right right eye ball,<br>"+
061         "and wait till it changes color<br> "+
062         "click x to make clicking sound work and c to make hit sound work";
063     setHelpText(helpText);
064   }
065   /**making boundary outside the face*/
066   private void boundary()
067   {
068     rec1=new RectangleSprite(2,2);
069     boundary5=new OutlineSprite(rec1);
070     boundary5.setScale(1.0);
071     boundary5.setColor(Palette.getColor("Black"));
072     boundary5.setLineThickness(0.0001);
073     boundary5.setLocation(0.50.5);
074     addSprite(boundary5);
075   }
076   /**making a yellow ball*/
077   private void makeBall()
078   {
079     ball=new OvalSprite(1,1);
080     ball.setScale(0.01);
081     ball.setLocation(0.50.5);
082     ball.setColor(Palette.getColor("yellow"));
083     addSprite(ball);
084   }
085   /** making a rectangle and adding a spinner*/
086   private void rectangle()
087   {
088     rec2=new RectangleSprite(1,1);
089     rec2.setScale(0.1);
090     rec2.setLocation(0.20.5);
091     rec2.setColor(Palette.getColor("red"));
092     addSprite(rec2);
093 
094     Spinner spinner;
095     spinner=new Spinner(0);
096     spinner.setRotationDegrees(65);
097     rec2.addTransformer(spinner);
098   }
099   /** making a rectangle and adding a spinner*/
100   private void rectangleSecond()
101   {
102     rec3=new RectangleSprite(1,1);
103     rec3.setScale(0.1);
104     rec3.setLocation(0.70.5);
105     rec3.setColor(Palette.getColor("red"));
106     addSprite(rec3);
107 
108     Spinner spinner2;
109     spinner2=new Spinner(0);
110     spinner2.setRotationDegrees(65);
111     rec3.addTransformer(spinner2);
112   }
113   /**making image in the background*/
114   private void face()
115   {
116     face=new ImageSprite("Face.JPG");
117     face.setLocation(0.50.5);
118     addSprite(face);
119   }
120   /**add a Text In the background the name of the title
121   and the name of the author*/
122   private void nameArt()
123   {
124     title= new StringSprite("The Wacky Face");
125     title.setScale(0.3);
126     title.setLocation(0.50.05);
127     title.setColor(Palette.getColor("White"));
128     canvas.addSprite(title);
129 
130     name=new StringSprite("Min Kim");
131     name.setScale(0.2);
132     name.setLocation(0.50.95);
133     name.setColor(Palette.getColor("White"));
134     canvas.addSprite(name);
135   }
136   /**making an eye outline with hollow*/
137   private void eye1()
138   {
139     eye1=new OvalSprite (21);
140     OutlineSprite outline1=new OutlineSprite(eye1);
141     outline1.setSize(.3);
142     outline1.setLineThickness(0.2);
143     outline1.setLocation(.2.3);
144     canvas.addSprite(outline1);
145   }
146   /**making an second eye on the right side*/
147   private void eye2()
148   {
149     eye2=new OvalSprite(21);
150     OutlineSprite outline2=new OutlineSprite(eye2);
151     outline2.setSize(.3);
152     outline2.setLineThickness(0.2);
153     outline2.setLocation(.7.3);
154     canvas.addSprite(outline2);
155   }
156   /**make eye ball inside the eye*/
157   private void eye3()
158   {
159     eye3= new OvalSprite(1,1);
160     eye3.setSize(.05);
161     eye3.setLocation(.2,.3);
162     canvas.addSprite(eye3);
163   }
164   /**makes the left eye left movement*/
165   private void moveLeft()
166   {
167     OutlineTransformer left;
168     left=new OutlineTransformer(0.25,
169                                 0.20.3,
170                                 0.10.3,
171                                 0.20.3);
172     left.setLooping(false);
173 
174     eye3.addTransformer(left);
175     eye3.setLocation(left.getCurrentPoint());
176     addSprite(eye3);
177   }
178   /**makes the right eye ball*/
179   private void eye4()
180   {
181     eye4=new OvalSprite(1,1);
182     eye4.setSize(.05);
183     eye4.setLocation(.7.3);
184     canvas.addSprite(eye4);
185   }
186   /**makes the right eye ball move right in the beginning*/
187   private void moveRight()
188   {
189     OutlineTransformer right;
190     right=new OutlineTransformer(0.25,
191                                  0.70.3,
192                                  0.80.3,
193                                  0.70.3);
194     right.setLooping(false);
195 
196     eye4.addTransformer(right);
197     eye4.setLocation(right.getCurrentPoint());
198     addSprite(eye4);
199   }
200   /**makes the outline of oval that looks like a mouth one small and one big
201   also used a blinker*/
202   private void makeMouth()
203   {
204     mouth1=new OvalSprite(21);
205     mouth1.setScale(0.4);
206     mouth1.setLocation(0.50.7);
207     mouth1.setColor(Palette.getColor("red"));
208     canvas.addSprite(mouth1);
209 
210     mouth2=new OvalSprite(21);
211     mouth2.setScale(0.2);
212     mouth2.setLocation(0.50.7);
213     mouth2.setColor(Palette.getColor("red"));
214     canvas.addSprite(mouth2);
215 
216     schedule(new Blinker().5);
217   }
218 
219   class Blinker extends TimedAction
220   {
221     public void act()
222     {
223       boolean vis=mouth1.isVisible();
224       mouth1.setVisible(!vis);
225       schedule(this.5);
226     }
227   }
228   class DelayedResponse extends TimedAction
229   {
230     public void act()
231     {
232       eye4.setColor(getColor("white"));
233     }
234   }
235   private void handleCollisions()
236   {
237     ball.bounceOffOf(boundary5);
238     ball.bounceOffOf(eye1);
239     ball.bounceOffOf(eye2);
240     ball.bounceOffOf(mouth1);
241     ball.bounceOffOf(mouth2);
242   }
243   /**handle input and game events*/
244   public void advance()
245   {
246     handleCollisions();
247     if(getKeyPressed()== 'z')
248     {
249       moveRight();
250     }
251     if(getKeyPressed()== 'a')
252     {
253       moveLeft();
254     }
255     if(getKeyPressed()== 'x')
256     {
257       playSoundImmediately();
258       sound1.setVolume(.8);
259       sound1.loop();
260     }
261     if(getKeyPressed()== 'c')
262     {
263       playSoundImmediately();
264       sound2.setVolume(.2);
265       sound2.loop();
266     }
267     if(getClick2D()!=null)
268     {
269       schedule(new DelayedResponse()1.5);
270     }
271   }
272 }


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