|
001 packagepackage is used to name the directory or folder a class is in JacobOlson;
002
003 importimport means to make the classes and/or packages available in this program wiki.Wiki;
004 importimport means to make the classes and/or packages available in this program fang.*;
005 importimport means to make the classes and/or packages available in this program java.awt.*;
006 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
007
008 /**
009 * All about my game here.
010 * @authorthis is the Javadoc tag for documenting who created the source code Jolson
011 */
012 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects DoorGameExperiment extendsextends means to customize or extend the functionality of a class GameLoop
013 {open braces start code blocks and must be matched with a close brace
014 privateprivate is used to restrict access to the current class only RectangleSprite back;
015 privateprivate is used to restrict access to the current class only RectangleSprite box1, box2, box3;
016 privateprivate is used to restrict access to the current class only Sprite door1, door2, door3;
017 privateprivate is used to restrict access to the current class only ImageSprite dot1, dot2, dot3;
018 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer x, y;
019 privateprivate is used to restrict access to the current class only StringSprite title, begin, end, win, lose;
020 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer stage;
021
022 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
023 {open braces start code blocks and must be matched with a close brace
024 stage=this assignment operator makes the left side equal to the right side0;
025 makeSprite();
026 addSprite();
027 y=this assignment operator makes the left side equal to the right siderandom.nextInt(3);
028 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same0)
029 {open braces start code blocks and must be matched with a close brace
030 dot1.setLocation(.2,.5);
031 dot2.setLocation(.5,.5);
032 dot3.setLocation(.8,.5);
033 }close braces end code blocks and must match an earlier open brace
034 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same1)
035 {open braces start code blocks and must be matched with a close brace
036 dot2.setLocation(.2,.5);
037 dot1.setLocation(.5,.5);
038 dot3.setLocation(.8,.5);
039 }close braces end code blocks and must match an earlier open brace
040 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same2)
041 {open braces start code blocks and must be matched with a close brace
042 dot3.setLocation(.2,.5);
043 dot2.setLocation(.5,.5);
044 dot1.setLocation(.8,.5);
045 }close braces end code blocks and must match an earlier open brace
046 x=this assignment operator makes the left side equal to the right siderandom.nextInt(2);
047 }close braces end code blocks and must match an earlier open brace
048
049 privateprivate is used to restrict access to the current class only Sprite getWinning()
050 {open braces start code blocks and must be matched with a close brace
051 SpringSprite status=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("You Win!");
052 status.setScale(.85);
053 status.setLocation(.5,.8);
054 status.setColor(Color.BLACK);
055 returnreturn means to provide the result of the method and/or cease execution of the method immediately status;
056 }close braces end code blocks and must match an earlier open brace
057 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprite()
058 {open braces start code blocks and must be matched with a close brace
059 back=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 1);
060 back.setScale(1);
061 back.setLocation(.5,.5);
062 back.setColor(Color.GREEN);
063
064 box2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 1.2);
065 box2.setScale(.3);
066 box2.setLocation(.5,.5);
067 box2.setColor(Color.RED);
068
069 box1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 1.2);
070 box1.setScale(.3);
071 box1.setLocation(.2,.5);
072 box1.setColor(Color.RED);
073
074 box3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 1.2);
075 box3.setScale(.3);
076 box3.setLocation(.8,.5);
077 box3.setColor(Color.RED);
078
079 title=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Lets Make a Deal!!!");
080 title.setScale(.8);
081 title.setLocation(.5,.2);
082 title.setColor(Color.BLACK);
083
084 begin=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Pick a Door");
085 begin.setScale(.8);
086 begin.setLocation(.5,.8);
087 begin.setColor(Color.BLACK);
088
089 end=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Keep or Change");
090 end.setScale(.8);
091 end.setLocation(.5,.8);
092 end.setColor(Color.BLACK);
093
094 door1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Door 1");
095 door1.setScale(.2);
096 door1.setLocation(.2,.5);
097 door1.setColor(Color.WHITE);
098
099 door2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Door 2");
100 door2.setScale(.2);
101 door2.setLocation(.5,.5);
102 door2.setColor(Color.WHITE);
103
104 door3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Door 3");
105 door3.setScale(.2);
106 door3.setLocation(.8,.5);
107 door3.setColor(Color.WHITE);
108
109 /**This is where i got it
110 *http://www.gabaritov.net/rus/auto/Porsche/porsche_Carrera_GT_001a.jpg
111 */
112 dot1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("CarPrize.jpg"));
113 dot1.setScale(.2);
114
115 /**This is where i got it
116 *http://www.healiohealth.com/images/products/Stainless-Trash-Infrared-Trash-Can-26.5-X-11.5-Inches-1.3Gstn-b.jpg
117 */
118 dot2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("SilverTrash.jpg"));
119 dot2.setScale(.2);
120
121 dot3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("SilverTrash.jpg"));
122 dot3.setScale(.2);
123 }close braces end code blocks and must match an earlier open brace
124 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprite()
125 {open braces start code blocks and must be matched with a close brace
126 canvas.addSprite(back);
127 canvas.addSprite(dot1);
128 canvas.addSprite(dot2);
129 canvas.addSprite(dot3);
130 canvas.addSprite(box1);
131 canvas.addSprite(box2);
132 canvas.addSprite(box3);
133 canvas.addSprite(door1);
134 canvas.addSprite(door2);
135 canvas.addSprite(door3);
136 canvas.addSprite(title);
137 }close braces end code blocks and must match an earlier open brace
138 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advanceFrame(doubledouble is the type for numbers that can contain decimal fractions timePassed)
139 {open braces start code blocks and must be matched with a close brace
140 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
141 ifif executes the next statement only if the condition in parenthesis evaluates to true(click!=this is the not equals operator which evaluates to true if both sides are differentnullnull is the value used to refer to a non-existant object)
142 {open braces start code blocks and must be matched with a close brace
143 ifif executes the next statement only if the condition in parenthesis evaluates to true(box1.intersects(click))
144 {open braces start code blocks and must be matched with a close brace
145 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same0)
146 {open braces start code blocks and must be matched with a close brace
147 ifif executes the next statement only if the condition in parenthesis evaluates to true(x==this is the comparison operator which evaluates to true if both sides are the same0)
148 {open braces start code blocks and must be matched with a close brace
149 canvas.removeSprite(box2);
150 canvas.removeSprite(door2);
151 }close braces end code blocks and must match an earlier open brace
152 ifif executes the next statement only if the condition in parenthesis evaluates to true(x==this is the comparison operator which evaluates to true if both sides are the same1)
153 {open braces start code blocks and must be matched with a close brace
154 canvas.removeSprite(box3);
155 canvas.removeSprite(door3);
156 }close braces end code blocks and must match an earlier open brace
157 }close braces end code blocks and must match an earlier open brace
158 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same1)
159 {open braces start code blocks and must be matched with a close brace
160 canvas.removeSprite(door3);
161 canvas.removeSprite(box3);
162 }close braces end code blocks and must match an earlier open brace
163 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same2)
164 {open braces start code blocks and must be matched with a close brace
165 canvas.removeSprite(door2);
166 canvas.removeSprite(box2);
167 }close braces end code blocks and must match an earlier open brace
168 }close braces end code blocks and must match an earlier open brace
169 ifif executes the next statement only if the condition in parenthesis evaluates to true(box2.intersects(click))
170 {open braces start code blocks and must be matched with a close brace
171 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same1)
172 {open braces start code blocks and must be matched with a close brace
173 ifif executes the next statement only if the condition in parenthesis evaluates to true(x==this is the comparison operator which evaluates to true if both sides are the same0)
174 {open braces start code blocks and must be matched with a close brace
175 canvas.removeSprite(box1);
176 canvas.removeSprite(door1);
177 }close braces end code blocks and must match an earlier open brace
178 ifif executes the next statement only if the condition in parenthesis evaluates to true(x==this is the comparison operator which evaluates to true if both sides are the same1)
179 {open braces start code blocks and must be matched with a close brace
180 canvas.removeSprite(box3);
181 canvas.removeSprite(door3);
182 }close braces end code blocks and must match an earlier open brace
183 }close braces end code blocks and must match an earlier open brace
184 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same0)
185 {open braces start code blocks and must be matched with a close brace
186 canvas.removeSprite(door3);
187 canvas.removeSprite(box3);
188 }close braces end code blocks and must match an earlier open brace
189 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same2)
190 {open braces start code blocks and must be matched with a close brace
191 canvas.removeSprite(door1);
192 canvas.removeSprite(box1);
193 }close braces end code blocks and must match an earlier open brace
194 }close braces end code blocks and must match an earlier open brace
195 ifif executes the next statement only if the condition in parenthesis evaluates to true(box3.intersects(click))
196 {open braces start code blocks and must be matched with a close brace
197 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same2)
198 {open braces start code blocks and must be matched with a close brace
199 ifif executes the next statement only if the condition in parenthesis evaluates to true(x==this is the comparison operator which evaluates to true if both sides are the same0)
200 {open braces start code blocks and must be matched with a close brace
201 canvas.removeSprite(box1);
202 canvas.removeSprite(door1);
203 }close braces end code blocks and must match an earlier open brace
204 ifif executes the next statement only if the condition in parenthesis evaluates to true(x==this is the comparison operator which evaluates to true if both sides are the same1)
205 {open braces start code blocks and must be matched with a close brace
206 canvas.removeSprite(box2);
207 canvas.removeSprite(door2);
208 }close braces end code blocks and must match an earlier open brace
209 }close braces end code blocks and must match an earlier open brace
210 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same1)
211 {open braces start code blocks and must be matched with a close brace
212 canvas.removeSprite(door1);
213 canvas.removeSprite(box1);
214 }close braces end code blocks and must match an earlier open brace
215 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same0)
216 {open braces start code blocks and must be matched with a close brace
217 canvas.removeSprite(door2);
218 canvas.removeSprite(box2);
219 }close braces end code blocks and must match an earlier open brace
220 }close braces end code blocks and must match an earlier open brace
221 }close braces end code blocks and must match an earlier open brace
222 }close braces end code blocks and must match an earlier open brace
223 }close braces end code blocks and must match an earlier open brace
|