LetsMakeADeal

From ggc

Jump to: navigation, search

001 import fang.*;
002 import java.awt.*;
003 import java.awt.geom.*;
004 
005 /**
006  * All about my game here.
007  @author Valerie Hagen
008  */
009 public class LetsMakeADeal extends GameLoop
010 {
011   private Sprite  box1;
012   private Sprite  box2;
013   private Sprite  box3;
014   private StringSprite box1Sprite;
015   private StringSprite box2Sprite;
016   private StringSprite box3Sprite;
017   private StringSprite box4Sprite;
018   private StringSprite box5Sprite;
019   private Sprite dot;
020   private ImageSprite diamond;
021   private Sprite explosion;
022   private Sprite explosion2;
023   private int prize;
024 
025 
026 
027   public void startGame()
028   {
029     makeSprites();
030     addSprites();
031     toggleAudible();
032   }
033 
034   private void makeSprites()
035   {
036 
037     Sound sound=new Sound("Applause2.wav");
038     sound.play(0.25);
039 
040     box1=new RectangleSprite(11);
041     box1.setScale(0.25);
042     box1.setLocation(.1.5);
043 
044     box2=new RectangleSprite(11);
045     box2.setScale(0.25);
046     box2.setLocation(0.50.5);
047 
048     box3=new RectangleSprite(11);
049     box3.setScale(0.25);
050     box3.setLocation(.9,.5);
051 
052 
053     box1Sprite=new StringSprite("Door 1");
054     box1Sprite.setHeight(0.05);
055     box1Sprite.setLocation(.1.7);
056 
057     box2Sprite=new StringSprite("Door 2");
058     box2Sprite.setHeight(0.05);
059     box2Sprite.setLocation(.5.7);
060 
061     box3Sprite=new StringSprite("Door 3");
062     box3Sprite.setHeight(0.05);
063     box3Sprite.setLocation(.9.7);
064 
065     box4Sprite=new StringSprite("Lets Make A Deal!");
066     box4Sprite.setHeight(0.09);
067     box4Sprite.setLocation(.5.1);
068 
069     box5Sprite=new StringSprite("By Valerie Hagen!");
070     box5Sprite.setHeight(0.05);
071     box5Sprite.setLocation(.5.9);
072 
073     Ellipse2D.Double circle=
074         new Ellipse2D.Double(0011);
075 
076 
077     diamond=new ImageSprite(Wiki.getMedia("Diamond.gif"));
078     diamond.setScale(0.1);
079     diamond.setColor(Color.RED);
080 
081 
082     explosion=new ImageSprite(Wiki.getMedia("Explosion.gif"));
083     explosion.setScale(0.1);
084     explosion.setColor(Color.RED);
085 
086     explosion2=new ImageSprite(Wiki.getMedia("Explosion.gif"));
087     explosion2.setScale(0.1);
088     explosion2.setColor(Color.GREEN);
089 
090 
091     prize=random.nextInt(3)+1;
092     if(prize==1)
093 
094     {
095       diamond.setLocation(.10.5);
096       explosion.setLocation(0.50.5);
097       explosion2.setLocation(0.90.5);
098     }
099     if(prize==2)
100     {
101       diamond.setLocation(0.90.5);
102       explosion.setLocation(0.10.5);
103       explosion2.setLocation(0.50.5);
104     }
105     if (prize==3)
106     {
107       diamond.setLocation(.50.5);
108       explosion.setLocation(0.90.5);
109       explosion2.setLocation(0.10.5);
110     }
111 
112 
113   }
114 
115   private void addSprites()
116   {
117 
118     canvas.addSprite(diamond);
119     canvas.addSprite(explosion);
120     canvas.addSprite(explosion2);
121     canvas.addSprite(box1);
122     canvas.addSprite(box2);
123     canvas.addSprite(box3);
124     canvas.addSprite(box1Sprite);
125     canvas.addSprite(box2Sprite);
126     canvas.addSprite(box3Sprite);
127     canvas.addSprite(box4Sprite);
128     canvas.addSprite(box5Sprite);
129 
130 
131 
132 
133 
134   }
135 
136   public void advanceFrame(double timePassed)
137   {
138     Point2D.Double click=getPlayer().getMouse().getClickLocation();
139     //did they click at all
140     if(click!=null)
141     {
142       if(box1.intersects(click))
143       {
144         canvas.removeSprite(box2);
145 
146 
147       }
148       if(box2.intersects(click))
149       {
150         canvas.removeSprite(box3);
151 
152 
153       }
154       if(box3.intersects(click))
155       {
156         canvas.removeSprite(box1);
157 
158 
159 
160       }
161     }
162   }
163 }
164 

Compiler Errors:
----------
1. ERROR in LetsMakeADeal.java (at line 40)
	box1=new RectangleSprite(1, 1);
	     ^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor RectangleSprite(int, int) is undefined
----------
2. ERROR in LetsMakeADeal.java (at line 40)
	box1=new RectangleSprite(1, 1);
	     ^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
9 problems (9 errors)

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