Blake/LetsMakeADeal

From ggc

Jump to: navigation, search

001 package Blake;
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 Blake Erskine
011  */
012 public class LetsMakeADeal extends GameLoop
013 {
014   /**a door*/
015   private Sprite door1;
016   private Sprite door2;
017   private Sprite door3;
018   private Sprite prize1;
019   private Sprite prize2;
020   private Sprite prize3;
021   private int i;
022   private int clickcount = 0;
023   private int ii;
024   private int doorpicked;
025   private int notopen;
026   private int open;
027   private Sprite crackerjack;
028   private StringSprite winmsg;
029   private StringSprite losemsg;
030 
031 
032   /**sets up the game*/
033   public void startGame()
034   {
035     makeSprites();
036     addSprites();
037   }
038 
039   /**makes the sprites*/
040   private void makeSprites()
041   {
042     /**Prizes*/
043     /**Prize 1*/
044     prize1=new RectangleSprite(12);
045     prize1.setScale(0.5);
046     prize1.setLocation(.20.5);
047     prize1.setColor(Color.RED);
048     /**Prize 2*/
049     prize2=new RectangleSprite(12);
050     prize2.setScale(0.5);
051     prize2.setLocation(.50.5);
052     prize2.setColor(Color.RED);
053     /**Prize 3*/
054     prize3=new RectangleSprite(12);
055     prize3.setScale(0.5);
056     prize3.setLocation(.80.5);
057     prize3.setColor(Color.GREEN);
058     /**Doors*/
059     /**Door 1*/
060     door1=new RectangleSprite(12);
061     door1.setScale(0.5);
062     door1.setLocation(.20.5);
063     /**Door 2*/
064     door2=new RectangleSprite(12);
065     door2.setScale(0.5);
066     door2.setLocation(.50.5);
067     /**Door 3*/
068     door3=new RectangleSprite(12);
069     door3.setScale(0.5);
070     door3.setLocation(.80.5);
071     /**Win Message*/
072     winmsg= new StringSprite("You Win");
073     winmsg.scale(.5);
074     winmsg.setLocation(.5,.20);
075     /**Lose Message*/
076     losemsg= new StringSprite("You Lose");
077     losemsg.scale(.5);
078     losemsg.setLocation(.5,.20);
079 
080     crackerjack = new StringSprite("Press q to Stay. Press w to Switch");
081     crackerjack.setLocation(.4.1);
082     crackerjack.setScale(.5);
083   }
084 
085   /**adds the sprites to the screen*/
086   private void addSprites()
087   {
088     canvas.addSprite(door1);
089     canvas.addSprite(door2);
090     canvas.addSprite(door3);
091 
092   }
093 
094   /**handle input and game events*/
095   public void advanceFrame(double timePassed)
096   {
097     if (getPlayer().getKeyboard().getLastKey() == 'q')
098     {
099       if (clickcount==1)
100       {
101         ii = random.nextInt(2);
102         if (doorpicked==&& notopen == 3)
103         {
104           if(ii == 0)
105           {
106             prize3.setLocation(door1.getLocation());
107             prize2.setLocation(door3.getLocation());
108             canvas.addSprite(winmsg);
109           }
110           if(ii == 1)
111           {
112             prize2.setLocation(door1.getLocation());
113             prize3.setLocation(door3.getLocation());
114             canvas.addSprite(losemsg);
115           }
116         }
117         if (doorpicked==&& notopen == 2)
118         {
119           if(ii == 0)
120           {
121             prize3.setLocation(door1.getLocation());
122             prize2.setLocation(door2.getLocation());
123             canvas.addSprite(winmsg);
124           }
125           if(ii == 1)
126           {
127             prize2.setLocation(door1.getLocation());
128             prize3.setLocation(door2.getLocation());
129             canvas.addSprite(losemsg);
130           }
131         }
132         if (doorpicked==&& notopen == 1)
133         {
134           if(ii == 0)
135           {
136             prize3.setLocation(door2.getLocation());
137             prize2.setLocation(door1.getLocation());
138             canvas.addSprite(winmsg);
139           }
140           if(ii == 1)
141           {
142             prize2.setLocation(door2.getLocation());
143             prize3.setLocation(door1.getLocation());
144             canvas.addSprite(losemsg);
145           }
146         }
147         if (doorpicked==&& notopen == 3)
148         {
149           if(ii == 0)
150           {
151             prize3.setLocation(door2.getLocation());
152             prize2.setLocation(door3.getLocation());
153             canvas.addSprite(winmsg);
154           }
155           if(ii == 1)
156           {
157             prize2.setLocation(door2.getLocation());
158             prize3.setLocation(door3.getLocation());
159             canvas.addSprite(losemsg);
160           }
161         }
162         if (doorpicked==&& notopen == 1)
163         {
164           if(ii == 0)
165           {
166             prize3.setLocation(door3.getLocation());
167             prize2.setLocation(door1.getLocation());
168             canvas.addSprite(winmsg);
169           }
170           if(ii == 1)
171           {
172             prize2.setLocation(door3.getLocation());
173             prize3.setLocation(door1.getLocation());
174             canvas.addSprite(losemsg);
175           }
176         }
177         if (doorpicked==&& notopen == 2)
178         {
179           if(ii == 0)
180           {
181             prize3.setLocation(door3.getLocation());
182             prize2.setLocation(door2.getLocation());
183             canvas.addSprite(winmsg);
184           }
185           if(ii == 1)
186           {
187             prize2.setLocation(door3.getLocation());
188             prize3.setLocation(door1.getLocation());
189             canvas.addSprite(losemsg);
190           }
191         }
192 
193         canvas.removeSprite(door1);
194         canvas.removeSprite(door2);
195         canvas.removeSprite(door3);
196         canvas.addSprite(prize2);
197         canvas.addSprite(prize3);
198       }
199     }
200 
201     if(getPlayer().getKeyboard().getLastKey() == 'w')
202       if (clickcount==1)
203       {
204         ii = random.nextInt(2);
205         if (doorpicked==&& notopen == 3)
206         {
207           if(ii == 1)
208           {
209             prize3.setLocation(door1.getLocation());
210             prize2.setLocation(door3.getLocation());
211             canvas.addSprite(losemsg);
212           }
213           if(ii == 0)
214           {
215             prize2.setLocation(door1.getLocation());
216             prize3.setLocation(door3.getLocation());
217             canvas.addSprite(winmsg);
218           }
219         }
220         if (doorpicked==&& notopen == 2)
221         {
222           if(ii == 1)
223           {
224             prize3.setLocation(door1.getLocation());
225             prize2.setLocation(door2.getLocation());
226             canvas.addSprite(losemsg);
227           }
228           if(ii == 0)
229           {
230             prize2.setLocation(door1.getLocation());
231             prize3.setLocation(door2.getLocation());
232             canvas.addSprite(winmsg);
233           }
234         }
235         if (doorpicked==&& notopen == 1)
236         {
237           if(ii == 1)
238           {
239             prize3.setLocation(door2.getLocation());
240             prize2.setLocation(door1.getLocation());
241             canvas.addSprite(losemsg);
242           }
243           if(ii == 0)
244           {
245             prize2.setLocation(door2.getLocation());
246             prize3.setLocation(door1.getLocation());
247             canvas.addSprite(winmsg);
248           }
249         }
250         if (doorpicked==&& notopen == 3)
251         {
252           if(ii == 1)
253           {
254             prize3.setLocation(door2.getLocation());
255             prize2.setLocation(door3.getLocation());
256             canvas.addSprite(losemsg);
257 
258           }
259           if(ii == 0)
260           {
261             prize2.setLocation(door2.getLocation());
262             prize3.setLocation(door3.getLocation());
263             canvas.addSprite(winmsg);
264           }
265         }
266         if (doorpicked==&& notopen == 1)
267         {
268           if(ii == 1)
269           {
270             prize3.setLocation(door3.getLocation());
271             prize2.setLocation(door1.getLocation());
272             canvas.addSprite(losemsg);
273           }
274           if(ii == 0)
275           {
276             prize2.setLocation(door3.getLocation());
277             prize3.setLocation(door1.getLocation());
278             canvas.addSprite(winmsg);
279           }
280         }
281         if (doorpicked==&& notopen == 2)
282         {
283           if(ii == 1)
284           {
285             prize3.setLocation(door3.getLocation());
286             prize2.setLocation(door2.getLocation());
287             canvas.addSprite(losemsg);
288           }
289           if(ii == 0)
290           {
291             prize2.setLocation(door3.getLocation());
292             prize3.setLocation(door1.getLocation());
293             canvas.addSprite(winmsg);
294           }
295         }
296 
297         canvas.removeSprite(door1);
298         canvas.removeSprite(door2);
299         canvas.removeSprite(door3);
300         canvas.addSprite(prize2);
301         canvas.addSprite(prize3);
302       }
303     Point2D.Double click=getPlayer().getMouse().getClickLocation();
304     //did they click at all
305     if(click!=null && clickcount == 0)
306     {
307       if(door1.intersects(click))
308       {
309         canvas.addSprite(crackerjack);
310         clickcount=1;
311         int i=random.nextInt(2);
312         doorpicked=1;
313         if(i==0)
314         {
315           prize1.setLocation(door2.getLocation());
316           canvas.removeSprite(door2);
317           canvas.addSprite(prize1);
318           open=2;
319           notopen=3;
320         }
321         if(i==1)
322         {
323           prize1.setLocation(door3.getLocation());
324           canvas.removeSprite(door3);
325           canvas.addSprite(prize1);
326           open=3;
327           notopen=2;
328         }
329       }
330 
331       if(door2.intersects(click))
332       {
333         canvas.addSprite(crackerjack);
334         clickcount=1;
335         int t=random.nextInt(2);
336         doorpicked=2;
337         if(t==0)
338         {
339           prize1.setLocation(door1.getLocation());
340           canvas.removeSprite(door1);
341           canvas.addSprite(prize1);
342           open=1;
343           notopen=3;
344 
345         }
346         if(t==1)
347         {
348           prize1.setLocation(door3.getLocation());
349           canvas.removeSprite(door3);
350           canvas.addSprite(prize1);
351           open=3;
352           notopen=1;
353         }
354       }
355       if(door3.intersects(click))
356       {
357         canvas.addSprite(crackerjack);
358         clickcount=1;
359         int r=random.nextInt(2);
360         doorpicked=3;
361         if(r==0)
362         {
363           prize1.setLocation(door2.getLocation());
364           canvas.removeSprite(door2);
365           canvas.addSprite(prize1);
366           open=2;
367           notopen=1;
368         }
369         if(r==1)
370         {
371           prize1.setLocation(door1.getLocation());
372           canvas.removeSprite(door1);
373           canvas.addSprite(prize1);
374           open=1;
375           notopen=2;
376         }
377       }
378     }
379   }
380 }

Compiler Errors:
----------
1. WARNING in Blake/LetsMakeADeal.java (at line 12)
	public class LetsMakeADeal extends GameLoop
	             ^^^^^^^^^^^^^
The type LetsMakeADeal collides with a package
----------
1 problem (1 warning)

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