mcclarty/Interactive Art

From ggc

Jump to: navigation, search

001 package mcclarty;
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 Interactive_Art extends Game
012 {
013 
014   private ImageSprite auron;
015   private ImageSprite seph;
016   private ImageSprite sun;
017   private ImageSprite choco;
018   private ImageSprite moogle;
019   private StringSprite title;
020   private StringSprite author;
021   private OutlineTransformer chocomov;
022   private Sound sword=new Sound("Shogun.wav");
023   private Sound ding=new Sound("DingLower.wav");
024 
025   //*Sets up the game*/
026   public void setup()
027   {
028     String helpText=
029         "Press 'm' in order to make the moogle (small animal) blink.<br>"+
030 
031         "Click on the chocobo (bird) to make it move across the screen.<br>"+
032 
033         "Enjoy!";
034     setHelpText(helpText);
035     strings();
036     sun();
037     sephiroth();
038     auron();
039     moogle();
040     sound();
041     choco();
042 
043   }
044   //* Plays a sword fighting sound throughout the duration of the program.*/
045   public void sound()
046   {
047     playSoundImmediately();
048     sword.setVolume(0.5);
049     sword.loop();
050   }
051   //* Places Sephiroth into the game and causes him to move about.*/
052   public void sephiroth()
053   {
054     seph=new ImageSprite("Seph.png");
055     seph.setSize(0.35);
056     addSprite(seph);
057 
058     OutlineTransformer sephmov;
059     sephmov=new OutlineTransformer(0.45,0.1,0.5,0.45,0.5,0.35,0.35,0.1,0.5);
060     sephmov.setLooping(true);
061     seph.addTransformer(sephmov);
062     seph.setLocation(sephmov.getCurrentPoint());
063   }
064   /** Places Auron on the screen and causes him to move mirroring Sephiroth's movements.*/
065   public void auron()
066   {
067     auron=new ImageSprite("Auron.jpg");
068     auron.setSize(0.25);
069     addSprite(auron);
070 
071     OutlineTransformer auronmov;
072     auronmov=new OutlineTransformer(0.45,0.9,0.5,0.55,0.5,0.65,0.35,0.9,0.5);
073     auronmov.setLooping(true);
074     auron.addTransformer(auronmov);
075     auron.setLocation(auronmov.getCurrentPoint());
076   }
077   /** Places the title and author on screen.*/
078   public void strings()
079   {
080     title=new StringSprite("Final Fantasy Art");
081     title.setSize(0.5);
082     title.setLocation(0.5,0.1);
083     title.setColor(Palette.getColor("Red"));
084     addSprite(title);
085 
086     author=new StringSprite("By: John McClarty");
087     author.setSize(0.25);
088     author.setLocation(0.5,0.95);
089     author.setColor(Palette.getColor("Red"));
090     addSprite(author);
091   }
092   //* Places moogle on screen and schedules a blinker to being when the 'w' key is pressed.*/
093   public void moogle()
094   {
095     moogle=new ImageSprite("Moogle.jpg");
096     moogle.setLocation(0.25,0.75);
097     moogle.setSize(0.25);
098     addSprite(moogle);
099   }
100 
101   public void moogleAct()
102   {
103     if (getKeyPressed() == 'm')
104     {
105       schedule(new Blinker()0.25);
106       playSoundImmediately();
107       ding.setVolume(0.5);
108 
109     }
110   }
111 
112   class Blinker extends TimedAction
113   {
114     public void act()
115     {
116       boolean vis=moogle.isVisible();
117       moogle.setVisible(!vis);
118       schedule(this,0.25);
119     }
120   }
121 
122   //* Places a chocobo on screen and schedules him to move across screen when clicked on.*/
123   public void choco()
124   {
125     choco=new ImageSprite("Chocobo.jpg");
126     choco.setSize(0.25);
127     choco.setLocation(0.9,0.9);
128     addSprite(choco);
129 
130     OutlineTransformer chocomov;
131     chocomov=new OutlineTransformer(0.05,0.9,0.9,0.1,0.9);
132   }
133   class DelayedResponse extends TimedAction
134   {
135     public void act()
136     {
137       choco.addTransformer(chocomov);
138     }
139   }
140   public void chocoAct()
141   {
142     if(getClick2D()!=null && choco.intersects(getClick2D()))
143     {
144       schedule(new DelayedResponse()1.5);
145     }
146   }
147 
148   //* Places sun on screen and makes it move, blink, and spin.
149   public void sun()
150   {
151     sun=new ImageSprite("Mario-sun.jpg");
152     sun.setSize(0.15);
153     addSprite(sun);
154 
155     OutlineTransformer sunmov;
156     sunmov=new OutlineTransformer(0.5,0.1,0.1,0.5,0.3,0.9,0.1,0.1,0.1);
157     sunmov.setLooping(true);
158     sun.addTransformer(sunmov);
159     sun.setLocation(sunmov.getCurrentPoint());
160 
161     Spinner sunspin;
162     sunspin=new Spinner(0);
163     sunspin.setRotationDegrees(360);
164     sun.addTransformer(sunspin);
165 
166     schedule(new Blinker2()0.25);
167   }
168   class Blinker2 extends TimedAction
169   {
170     public void act()
171     {
172       boolean vis=sun.isVisible();
173       sun.setVisible(!vis);
174       schedule(this,0.25);
175     }
176   }
177 
178   public void advance()
179   {
180     chocoAct();
181     moogleAct();
182   }
183 }


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