MattC/MakeADeal

From ggc

Jump to: navigation, search

001 package MattC;
002 
003 import wiki.Wiki;
004 import fang.*;
005 import java.awt.*;
006 import java.awt.geom.*;
007 
008 /**
009  * All about my game here.
010  @author null
011  */
012 public class MakeADeal extends GameLoop
013 {
014   Sound sound=new Sound(Wiki.getMedia("Sound1.wav"));
015 
016   private Sprite title,text1,text2,text3;
017   private Sprite box1;
018   private Sprite box2;
019   private Sprite box3;
020   private ImageSprite prize1;
021   private ImageSprite prize2;
022   private ImageSprite prize3;
023   private int x,y;
024   private int clickcount = 0;
025 
026   public void startGame()
027   {
028     makeSprites();
029     addSprites();
030     toggleAudible();
031   }
032 
033   private void makeSprites()
034   {
035     title=new StringSprite("Lets Make A Deal!");
036     title.setScale(.75);
037     title.setLocation(.5.12);
038     title.setColor(Color.RED);
039 
040     text1=new StringSprite("Door 1");
041     text1.setScale(0.2);
042     text1.setLocation(0.150.83);
043     text1.setColor(Color.WHITE);
044 
045     text3=new StringSprite("Door 2");
046     text3.setScale(0.2);
047     text3.setLocation(0.50.83);
048     text3.setColor(Color.WHITE);
049 
050     text2=new StringSprite("Door 3");
051     text2.setScale(0.2);
052     text2.setLocation(0.850.83);
053     text2.setColor(Color.WHITE);
054 
055     box1=new RectangleSprite(11);
056     box1.setScale(0.25);
057     box1.setLocation(0.50.5);
058 
059     box2=new RectangleSprite(11);
060     box2.setScale(0.25);
061     box2.setLocation(.850.5);
062 
063     box3=new RectangleSprite(11);
064     box3.setScale(0.25);
065     box3.setLocation(.150.5);
066 
067     prize1=new ImageSprite(Wiki.getMedia("Moneyyy.jpg"));
068     prize1.setScale(0.2);
069 
070     prize2=new ImageSprite(Wiki.getMedia("Snakeee.jpg"));
071     prize2.setScale(0.2);
072 
073     prize3=new ImageSprite(Wiki.getMedia("Snakeee.jpg"));
074     prize3.setScale(0.2);
075 
076     y=random.nextInt(3);
077     if(y==0)
078     {
079       prize1.setLocation(0.50.5);
080       prize2.setLocation(0.150.5);
081       prize3.setLocation(0.850.5);
082     }
083     if(y==1)
084     {
085       prize1.setLocation(0.50.5);
086       prize2.setLocation(0.150.5);
087       prize3.setLocation(0.850.5);
088     }
089     if(y==2)
090     {
091       prize1.setLocation(0.50.5);
092       prize2.setLocation(0.150.5);
093       prize3.setLocation(0.850.5);
094     }
095 
096 
097   }
098 
099   private void addSprites()
100   {
101     canvas.addSprite(prize1);
102     canvas.addSprite(prize2);
103     canvas.addSprite(prize3);
104 
105     canvas.addSprite(box1);
106     canvas.addSprite(box2);
107     canvas.addSprite(box3);
108 
109     canvas.addSprite(title,text1,text2,text3);
110 
111   }
112 
113   public void advanceFrame(double timePassed)
114   {
115     Point2D.Double click=getPlayer().getMouse().getClickLocation();
116 
117     if(click!=null)
118     {
119       if(box1.intersects(click))
120       {
121         int i=random.nextInt(2);
122         if(i==0)
123         {
124           canvas.removeSprite(box2);
125           clickcount++;
126         }
127         if(i==1)
128         {
129           canvas.removeSprite(box3);
130           clickcount++;
131         }
132 
133       }
134       if(box2.intersects(click))
135       {
136         int t=random.nextInt(2);
137         if(t==0)
138         {
139           canvas.removeSprite(box1);
140           clickcount++;
141         }
142         if(t==1)
143         {
144           canvas.removeSprite(box3);
145           clickcount++;
146         }
147 
148       }
149 
150       if(box3.intersects(click))
151       {
152         int r=random.nextInt(2);
153         if(r==0)
154         {
155           canvas.removeSprite(box2);
156           clickcount++;
157         }
158         if(r==1)
159         {
160           canvas.removeSprite(box1);
161           clickcount++;
162         }
163       }
164 
165     }
166     if(clickcount==2)
167     {
168       canvas.removeSprite(box1);
169       canvas.removeSprite(box2);
170       canvas.removeSprite(box3);
171     }
172 
173 
174   }
175 }

Compiler Errors:
----------
1. WARNING in MattC/MakeADeal.java (at line 12)
	public class MakeADeal extends GameLoop
	             ^^^^^^^^^
The type MakeADeal collides with a package
----------
2. ERROR in MattC/MakeADeal.java (at line 67)
	prize1=new ImageSprite(Wiki.getMedia("Moneyyy.jpg"));
	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
4 problems (3 errors, 1 warning)

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