matt mitrovich kcie green/Montyhall2

From ggc

Jump to: navigation, search

001 package matt_mitrovich_kcie_green;
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 Montyhall2 extends Game
012 {
013   private int numclick;
014   private RectangleSprite square;
015   private RectangleSprite square2;
016   private RectangleSprite square3;
017   private RectangleSprite square4;
018   private RectangleSprite square5;
019   private RectangleSprite square6;
020   private RectangleSprite square7;
021 
022   /**sets up the game*/
023   public void setup()
024   {
025     numclick=0;
026 
027     square7=new RectangleSprite(.5,.5);
028     square7.setSize(.15);
029     square7.setLocation(0.80,0.50);
030     square7.setColor(Palette.getColor("RED"));
031     addSprite(square7);
032 
033     square4=new RectangleSprite(.5,.5);
034     square4.setSize(.15);
035     square4.setLocation(0.20,0.50);
036     square4.setColor(Palette.getColor("White"));
037     addSprite(square4);
038 
039     square5=new RectangleSprite(.5,.5);
040     square5.setSize(.15);
041     square5.setLocation(0.50,0.50);
042     square5.setColor(Palette.getColor("White"));
043     addSprite(square5);
044 
045     square6=new RectangleSprite(.5,.5);
046     square6.setSize(.15);
047     square6.setLocation(0.80,0.50);
048     square6.setColor(Palette.getColor("White"));
049     addSprite(square6);
050 
051 
052 
053     square=new RectangleSprite(1,1);
054     square.setSize(.25);
055     square.setLocation(0.20,0.50);
056     square.setColor(Palette.getColor("White"));
057     addSprite(square);
058 
059 
060     square2=new RectangleSprite(1,1);
061     square2.setSize(.25);
062     square2.setLocation(0.50,0.50);
063     square2.setColor(Palette.getColor("red"));
064     addSprite(square2);
065 
066 
067     square3=new RectangleSprite(1,1);
068     square3.setSize(.25);
069     square3.setLocation(0.80,0.50);
070     square3.setColor(Palette.getColor("blue"));
071     addSprite(square3);
072 
073   }
074 
075 
076 
077   /**handle input and game events*/
078   public void advance()
079   {
080     if(getClick2D()!=null && square.intersects(getClick2D()))
081 
082 
083     {
084 
085       square.setVisible(true);
086       square2.setVisible(false);
087       square3.setVisible(true);
088       square6.setColor(Palette.getColor("LIME"));
089       square5.setColor(Palette.getColor("RED"));
090       square4.setColor(Palette.getColor("RED"));
091       square6.setLocation(.80,.50);
092 
093 
094     }
095     else if(getClick2D()!=null && square2.intersects(getClick2D()))
096 
097 
098     {
099 
100       square.setVisible(true);
101       square2.setVisible(false);
102       square3.setVisible(true);
103       square6.setColor(Palette.getColor("LIME"));
104       square5.setColor(Palette.getColor("RED"));
105       square4.setColor(Palette.getColor("RED"));
106       square6.setLocation(.20,.50);
107 
108 
109     }
110     else if(getClick2D()!=null && square3.intersects(getClick2D()))
111 
112 
113     {
114 
115       square.setVisible(false);
116       square2.setVisible(false);
117       square3.setVisible(false);
118       square6.setColor(Palette.getColor("LIME"));
119       square5.setColor(Palette.getColor("RED"));
120       square4.setColor(Palette.getColor("RED"));
121       square6.setLocation(.20,.50);
122 
123     }
124   }
125 }


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