|
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 DoorGame 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, box1, box2, box3;
015 privateprivate is used to restrict access to the current class only Sprite door1, door2, door3;
016 privateprivate is used to restrict access to the current class only ImageSprite dot1, dot2, dot3;
017 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, stage;
018 privateprivate is used to restrict access to the current class only StringSprite title;
019 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer clickCount;
020
021 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
022 {open braces start code blocks and must be matched with a close brace
023 stage=this assignment operator makes the left side equal to the right side0;
024 makeSprite();
025 addSprite();
026 y=this assignment operator makes the left side equal to the right siderandom.nextInt(3);
027 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)
028 {open braces start code blocks and must be matched with a close brace
029 dot1.setLocation(.2,.5);
030 dot2.setLocation(.5,.5);
031 dot3.setLocation(.8,.5);
032 }close braces end code blocks and must match an earlier open brace
033 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)
034 {open braces start code blocks and must be matched with a close brace
035 dot2.setLocation(.2,.5);
036 dot1.setLocation(.5,.5);
037 dot3.setLocation(.8,.5);
038 }close braces end code blocks and must match an earlier open brace
039 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)
040 {open braces start code blocks and must be matched with a close brace
041 dot3.setLocation(.2,.5);
042 dot2.setLocation(.5,.5);
043 dot1.setLocation(.8,.5);
044 }close braces end code blocks and must match an earlier open brace
045 x=this assignment operator makes the left side equal to the right siderandom.nextInt(2);
046 }close braces end code blocks and must match an earlier open brace
047 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprite()
048 {open braces start code blocks and must be matched with a close brace
049 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);
050 back.setScale(1);
051 back.setLocation(.5,.5);
052 back.setColor(Color.BLUE);
053
054 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);
055 box2.setScale(.3);
056 box2.setLocation(.5,.5);
057 box2.setColor(Color.RED);
058
059 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);
060 box1.setScale(.3);
061 box1.setLocation(.2,.5);
062 box1.setColor(Color.RED);
063
064 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);
065 box3.setScale(.3);
066 box3.setLocation(.8,.5);
067 box3.setColor(Color.RED);
068
069 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!!!");
070 title.setScale(.8);
071 title.setLocation(.5,.2);
072 title.setColor(Color.BLACK);
073
074 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");
075 door1.setScale(.2);
076 door1.setLocation(.2,.5);
077 door1.setColor(Color.WHITE);
078
079 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");
080 door2.setScale(.2);
081 door2.setLocation(.5,.5);
082 door2.setColor(Color.WHITE);
083
084 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");
085 door3.setScale(.2);
086 door3.setLocation(.8,.5);
087 door3.setColor(Color.WHITE);
088
089 /**This is where i got it
090 *http://www.gabaritov.net/rus/auto/Porsche/porsche_Carrera_GT_001a.jpg
091 */
092 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"));
093 dot1.setScale(.2);
094
095 /**This is where i got it
096 *http://www.healiohealth.com/images/products/Stainless-Trash-Infrared-Trash-Can-26.5-X-11.5-Inches-1.3Gstn-b.jpg
097 */
098 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"));
099 dot2.setScale(.2);
100
101 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"));
102 dot3.setScale(.2);
103 }close braces end code blocks and must match an earlier open brace
104 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprite()
105 {open braces start code blocks and must be matched with a close brace
106 canvas.addSprite(back);
107 canvas.addSprite(dot1);
108 canvas.addSprite(dot2);
109 canvas.addSprite(dot3);
110 canvas.addSprite(box1);
111 canvas.addSprite(box2);
112 canvas.addSprite(box3);
113 canvas.addSprite(door1);
114 canvas.addSprite(door2);
115 canvas.addSprite(door3);
116 canvas.addSprite(title);
117 }close braces end code blocks and must match an earlier open brace
118 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)
119 {open braces start code blocks and must be matched with a close brace
120 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
121 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)
122 {open braces start code blocks and must be matched with a close brace
123 ifif executes the next statement only if the condition in parenthesis evaluates to true(box1.intersects(click))
124 {open braces start code blocks and must be matched with a close brace
125 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)
126 {open braces start code blocks and must be matched with a close brace
127 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)
128 {open braces start code blocks and must be matched with a close brace
129 canvas.removeSprite(box2);
130 canvas.removeSprite(door2);
131 }close braces end code blocks and must match an earlier open brace
132 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)
133 {open braces start code blocks and must be matched with a close brace
134 canvas.removeSprite(box3);
135 canvas.removeSprite(door3);
136 }close braces end code blocks and must match an earlier open brace
137 }close braces end code blocks and must match an earlier open brace
138 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)
139 {open braces start code blocks and must be matched with a close brace
140 canvas.removeSprite(door3);
141 canvas.removeSprite(box3);
142 }close braces end code blocks and must match an earlier open brace
143 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)
144 {open braces start code blocks and must be matched with a close brace
145 canvas.removeSprite(door2);
146 canvas.removeSprite(box2);
147 }close braces end code blocks and must match an earlier open brace
148 }close braces end code blocks and must match an earlier open brace
149 ifif executes the next statement only if the condition in parenthesis evaluates to true(box2.intersects(click))
150 {open braces start code blocks and must be matched with a close brace
151 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)
152 {open braces start code blocks and must be matched with a close brace
153 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)
154 {open braces start code blocks and must be matched with a close brace
155 canvas.removeSprite(box1);
156 canvas.removeSprite(door1);
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(x==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(box3);
161 canvas.removeSprite(door3);
162 }close braces end code blocks and must match an earlier open brace
163 }close braces end code blocks and must match an earlier open brace
164 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)
165 {open braces start code blocks and must be matched with a close brace
166 canvas.removeSprite(door3);
167 canvas.removeSprite(box3);
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(y==this is the comparison operator which evaluates to true if both sides are the same2)
170 {open braces start code blocks and must be matched with a close brace
171 canvas.removeSprite(door1);
172 canvas.removeSprite(box1);
173 }close braces end code blocks and must match an earlier open brace
174 }close braces end code blocks and must match an earlier open brace
175 ifif executes the next statement only if the condition in parenthesis evaluates to true(box3.intersects(click))
176 {open braces start code blocks and must be matched with a close brace
177 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)
178 {open braces start code blocks and must be matched with a close brace
179 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)
180 {open braces start code blocks and must be matched with a close brace
181 canvas.removeSprite(box1);
182 canvas.removeSprite(door1);
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(x==this is the comparison operator which evaluates to true if both sides are the same1)
185 {open braces start code blocks and must be matched with a close brace
186 canvas.removeSprite(box2);
187 canvas.removeSprite(door2);
188 }close braces end code blocks and must match an earlier open brace
189 }close braces end code blocks and must match an earlier open brace
190 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)
191 {open braces start code blocks and must be matched with a close brace
192 canvas.removeSprite(door1);
193 canvas.removeSprite(box1);
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(y==this is the comparison operator which evaluates to true if both sides are the same0)
196 {open braces start code blocks and must be matched with a close brace
197 canvas.removeSprite(door2);
198 canvas.removeSprite(box2);
199 }close braces end code blocks and must match an earlier open brace
200 }close braces end code blocks and must match an earlier open brace
201 }close braces end code blocks and must match an earlier open brace
202 }close braces end code blocks and must match an earlier open brace
203 }close braces end code blocks and must match an earlier open brace
|