ChrisHull/Art

From ggc

Jump to: navigation, search

001 package ChrisHull;
002 
003 import wiki.Wiki;
004 import fang.*;
005 import java.awt.*;
006 import java.awt.geom.*;
007 import Beta.*;
008 
009 /**
010  * All about my game here.
011  @author Chull
012  */
013 public class Art extends GameLoop
014 {
015   /**where the user clicks*/
016   private Point2D.Double whereClick;
017   /** Displays Title of Art*/
018   private Sprite Text;
019   /** Displays monster nose*/
020   private Sprite monsterNose;
021   /** Displays monster mouth*/
022   private Sprite monsterMouth;
023   /** Displays monster eye*/
024   private Sprite monsterEye;
025   /** Displays monster eye*/
026   private Sprite monsterEye2;
027   /** Moves the monsters face for translation*/
028   private Sprite moving;
029   /** determines type of tracker*/
030   private ProjectileTracker tracker;
031   /** Declares Track Statement*/
032   private OutlineTracker track;
033   /** Makes image rotate*/
034   private Sprite rotate;
035   /** Plays good sound*/
036   private Sound sound;
037   /** Plays bad sound*/
038   private Sound soundSecond;
039 
040   /**sets up the game*/
041   public void startGame()
042   {
043     rotateSprite();
044     movingSprite();
045     makeSprites();
046     makeSounds();
047     addSprites();
048     scheduleRelative(new NameAppear()1);
049     /** Changes the text in help file*/
050     setHelpText(
051         "Watch the moving shapes<br><br>"+
052         "press 1 and 2 to hear  different sounds<br><br>"+
053         "Click Start to begin");
054 
055   }
056 
057 
058   /** determines how the sprite will move*/
059   private void movingSprite()
060   {
061     moving=new ImageSprite(Wiki.getMedia("Monstermouth.jpg"));
062     moving.setScale(0.3);
063     moving.setLocation(0.51);
064     track=new OutlineTracker (.2.5,.6 ,.5,.7);
065     track.setLooping(true);
066     moving.setTracker(track);
067     moving.setLocation(track.getCurrentPoint());
068     canvas.addSprite(moving);
069 
070   }
071 
072   /**modifys monsterEye2 with a Periodic event*/
073   private void PeriodicEvent()
074   {
075     Sprite sprite=new ImageSprite(Wiki.getMedia("Monstereye2.jpg"));
076     sprite.setScale(0.1);
077     sprite.setLocation(whereClick);
078     canvas.addSprite(sprite);
079 
080   }
081 
082 
083   /**calls PeriodicEvent when the alarm goes off*/
084   class PeriodicEvent implements Alarm
085   {
086     /**simply calls PerodicEvent*/
087     public void alarm()
088     {
089       monsterEye2.setVisible(!monsterEye2.isVisible());
090 
091       scheduleRelative(this,.5);
092 
093     }
094   }
095 
096 
097   /**tells what sound will play*/
098   private void makeSounds()
099   {
100     sound=new Sound(Wiki.getMedia("Ding.wav"));
101     soundSecond=new Sound(Wiki.getMedia("Boom.wav"));
102   }
103 
104 
105   /** determines what happens when you click*/
106   private void clickFirst()
107   {
108     Point2D.Double click=getPlayer().getMouse().getClickLocation();
109     //did they click at all
110     if(click!=null)
111       canvas.removeSprite(monsterEye);
112 
113   }
114 
115   /** determines how sprite will rotate*/
116   private void rotateSprite()
117   {
118     rotate=new ImageSprite(Wiki.getMedia("Monsternose.jpg"));
119     rotate.setScale(0.1);
120     rotate.setLocation(0.50.4);
121     Point2D.Double direction=new Point2D.Double(00);
122     ProjectileTracker pTracker=new ProjectileTracker(direction);
123     pTracker.setAngularVelocity(1);
124     rotate.setTracker(pTracker);
125     canvas.addSprite(rotate);
126 
127   }
128 
129   /** displays the title of art and artist name*/
130   private void displayName()
131   {
132 
133     Text=new StringSprite("Monster - Chris Hull");
134     Text.setScale(.4);
135     Text.setLocation(.5.1);
136     canvas.addSprite(Text);
137   }
138 
139 
140   /** Sets up a alarm so artist name and title apears in 1 second*/
141   class NameAppear implements Alarm
142   {
143     /** calls displayName*/
144     public void alarm()
145     {
146       displayName();
147     }
148   }
149 
150 
151   /**makes the sprites which composes the monsters face*/
152   private void makeSprites()
153   {
154 
155 
156     monsterEye=new ImageSprite(Wiki.getMedia("Monstereye.jpg"));
157     monsterEye.setScale(0.1);
158     monsterEye.setLocation(0.40.3);
159 
160     monsterEye2=new ImageSprite(Wiki.getMedia("Monstereye2.jpg"));
161     monsterEye2.setScale(0.1);
162     monsterEye2.setLocation(0.60.3);
163 
164 
165   }
166 
167   /**adds the sprites to the screen that belong to the monster*/
168   private void addSprites()
169 
170   {
171 
172     canvas.addSprite(monsterEye);
173     canvas.addSprite(monsterEye2);
174 
175   }
176 
177   /**handle input and game events*/
178   public void advanceFrame(double timePassed)
179   {
180     clickFirst();
181     if(getPlayer().getKeyboard().getLastKey()=='1')
182     {
183       sound.play(0);
184     }
185     if(getPlayer().getKeyboard().getLastKey()=='2')
186     {
187       soundSecond.play(1);
188     }
189     Point2D.Double click=getPlayer().getMouse().getClickLocation();
190     if(click!=null)
191     {
192       scheduleRelative(new PeriodicEvent()1);
193       whereClick=click;
194     }
195   }
196 
197 }

Compiler Errors:
----------
1. ERROR in ChrisHull/Art.java (at line 32)
	private OutlineTracker track;
	        ^^^^^^^^^^^^^^
The type OutlineTracker is ambiguous
----------
2. ERROR in ChrisHull/Art.java (at line 61)
	moving=new ImageSprite(Wiki.getMedia("Monstermouth.jpg"));
	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
11 problems (11 errors)

Download/View ChrisHull/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