|
001 packagepackage is used to name the directory or folder a class is in GBell;
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 importimport means to make the classes and/or packages available in this program Beta.OutlineTracker;
008
009 /**
010 * This is an interactive display of
011 * artistic audio, images, and movement
012 * @authorthis is the Javadoc tag for documenting who created the source code Geremy Bell
013 */
014 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 InteractiveArt extendsextends means to customize or extend the functionality of a class GameLoop
015 {open braces start code blocks and must be matched with a close brace
016 /**sprites*/
017 privateprivate is used to restrict access to the current class only Sprite diamond, diamond2, outline, outline2, background, spiral, polygon, twelve, three, six, nine, title, title2;
018 /**tracker to move diamonds*/
019 privateprivate is used to restrict access to the current class only OutlineTracker tracker, tracker2;
020 /**trackers forfor is a looping structure for repeatedly executing a block of code clock*/
021 privateprivate is used to restrict access to the current class only OutlineTracker tracker3, tracker4, tracker5, tracker6;
022 /**tracker to rotate center image*/
023 privateprivate is used to restrict access to the current class only ProjectileTracker center;
024 /**sets condition forfor is a looping structure for repeatedly executing a block of code audio and change in rotation*/
025 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false intersecting=this assignment operator makes the left side equal to the right sidefalsefalse is a value for the boolean type and means not true;
026 /**angular velocity forfor is a looping structure for repeatedly executing a block of code trackers*/
027 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;
028 /**sound when diamonds collide*/
029 privateprivate is used to restrict access to the current class only Sound sound=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Pluck.wav"));
030
031 /** starts game */
032 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
033 {open braces start code blocks and must be matched with a close brace
034 makeSprites();
035 setHelpText("Click to add random shapes with random colors. Press 'x' to change the clock colors. Enjoy!");
036 toggleAudible();
037 pauseToggle();
038 x=this assignment operator makes the left side equal to the right side3;
039 }close braces end code blocks and must match an earlier open brace
040
041 /** makes sprites and trackers */
042 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
043 {open braces start code blocks and must be matched with a close brace
044 title=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Interactive Art");
045 title.setScale(.3);
046 title.setColor(Color.RED);
047 title.setLocation(.5, .05);
048 canvas.addSprite(title);
049
050 title2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("by Geremy");
051 title2.setScale(.15);
052 title2.setColor(Color.GREEN);
053 title2.setLocation(.5, .97);
054 canvas.addSprite(title2);
055
056 createOutline();
057 createClock();
058 createDiamond();
059 createDiamond2();
060 createSpiral();
061 }close braces end code blocks and must match an earlier open brace
062
063 /** creates oval as path forfor is a looping structure for repeatedly executing a block of code tracker */
064 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value createOutline()
065 {open braces start code blocks and must be matched with a close brace
066 background=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
067 background.setScale(0.6);
068 background.setLocation(0.5, 0.5);
069 background.setColor(Color.black);
070 canvas.addSprite(background);
071
072 outline=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
073 outline.setScale(0.5);
074 outline.setLocation(0.5, 0.5);
075 outline.setColor(Color.WHITE);
076 canvas.addSprite(outline);
077
078 outline2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
079 outline2.setScale(0.43);
080 outline2.setLocation(0.5, 0.5);
081 outline2.setColor(Color.WHITE);
082 canvas.addSprite(outline2);
083
084 }close braces end code blocks and must match an earlier open brace
085
086 /**creates twelve and tracker forfor is a looping structure for repeatedly executing a block of code motion*/
087 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value createTwelve()
088 {open braces start code blocks and must be matched with a close brace
089 twelve=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("12");
090 twelve.setLocation(0.5, 0.2875);
091 twelve.setScale(.05);
092 twelve.setColor(Color.BLACK);
093 canvas.addSprite(twelve);
094
095 tracker3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTracker(outline2, -0.5);
096 twelve.setTracker(tracker3);
097 twelve.setLocation(tracker3.getCurrentPoint());
098 tracker3.setLooping(truetrue is the boolean value that is the opposite of false);
099 }close braces end code blocks and must match an earlier open brace
100
101 /**creates three and tracker forfor is a looping structure for repeatedly executing a block of code motion*/
102 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value createThree()
103 {open braces start code blocks and must be matched with a close brace
104 three=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("3");
105 three.setLocation(0.725, 0.5);
106 three.setScale(.05);
107 three.setColor(Color.BLACK);
108 canvas.addSprite(three);
109
110 tracker4=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTracker(outline2, -0.5);
111 three.setTracker(tracker4);
112 three.setLocation(tracker4.getCurrentPoint());
113 tracker4.setLooping(truetrue is the boolean value that is the opposite of false);
114 }close braces end code blocks and must match an earlier open brace
115
116 /**creates six and tracker forfor is a looping structure for repeatedly executing a block of code motion*/
117 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value createSix()
118 {open braces start code blocks and must be matched with a close brace
119 six=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("6");
120 six.setLocation(0.5, 0.72);
121 six.setScale(.05);
122 six.setColor(Color.BLACK);
123 canvas.addSprite(six);
124
125 tracker5=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTracker(outline2, -0.5);
126 six.setTracker(tracker5);
127 six.setLocation(tracker5.getCurrentPoint());
128 tracker5.setLooping(truetrue is the boolean value that is the opposite of false);
129 }close braces end code blocks and must match an earlier open brace
130
131 /**creates nine and tracker forfor is a looping structure for repeatedly executing a block of code motion*/
132 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value createNine()
133 {open braces start code blocks and must be matched with a close brace
134 nine=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("9");
135 nine.setLocation(0.28, 0.5);
136 nine.setScale(.05);
137 nine.setColor(Color.BLACK);
138 canvas.addSprite(nine);
139
140 tracker6=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTracker(outline2, -0.5);
141 nine.setTracker(tracker6);
142 nine.setLocation(tracker6.getCurrentPoint());
143 tracker6.setLooping(truetrue is the boolean value that is the opposite of false);
144 }close braces end code blocks and must match an earlier open brace
145
146 /**creates numbers and trackers forfor is a looping structure for repeatedly executing a block of code clock*/
147 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value createClock()
148 {open braces start code blocks and must be matched with a close brace
149 createTwelve();
150 createThree();
151 createSix();
152 createNine();
153 }close braces end code blocks and must match an earlier open brace
154
155 /** creates a diamond and sets it
156 * in motion given a tracker */
157 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value createDiamond()
158 {open braces start code blocks and must be matched with a close brace
159 diamond=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(4);
160 diamond.setScale(0.1);
161 canvas.addSprite(diamond);
162
163 tracker=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTracker(outline, -0.5);
164 diamond.setTracker(tracker);
165 diamond.setLocation(tracker.getCurrentPoint());
166 tracker.setLooping(truetrue is the boolean value that is the opposite of false);
167 }close braces end code blocks and must match an earlier open brace
168
169 /** creates a diamond and sets it
170 * in motion given a tracker */
171 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value createDiamond2()
172 {open braces start code blocks and must be matched with a close brace
173 diamond2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(4);
174 diamond2.setScale(0.1);
175 canvas.addSprite(diamond2);
176
177 tracker2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTracker(outline, 0.5);
178 diamond2.setTracker(tracker2);
179 diamond2.setLocation(tracker.getCurrentPoint());
180 tracker2.setLooping(truetrue is the boolean value that is the opposite of false);
181 }close braces end code blocks and must match an earlier open brace
182
183 /** creates spiral image and sets
184 * it in motion given a tracker */
185 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value createSpiral()
186 {open braces start code blocks and must be matched with a close brace
187 spiral=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Spiral4.png"));
188 spiral.setScale(0.3);
189 spiral.setLocation(0.5, 0.5);
190 canvas.addSprite(spiral);
191
192 Point2D.Double direction=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Point2D.Double(0.0, 0.0);
193 center=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(direction);
194 /** rotate 1/2 a revolution per second */
195 center.setAngularVelocity(x);
196 spiral.setTracker(center);
197 }close braces end code blocks and must match an earlier open brace
198
199 /** makes collision of diamonds change
200 * rotation of the center and play audio */
201 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
202 {open braces start code blocks and must be matched with a close brace
203 ifif executes the next statement only if the condition in parenthesis evaluates to true(diamond.intersects(diamond2))
204 {open braces start code blocks and must be matched with a close brace
205 ifif executes the next statement only if the condition in parenthesis evaluates to true(intersecting==this is the comparison operator which evaluates to true if both sides are the samefalsefalse is a value for the boolean type and means not true)
206 {open braces start code blocks and must be matched with a close brace
207 x=this assignment operator makes the left side equal to the right side-x;
208 center.setAngularVelocity(x);
209 sound.play();
210 intersecting=this assignment operator makes the left side equal to the right sidetruetrue is the boolean value that is the opposite of false;
211 }close braces end code blocks and must match an earlier open brace
212 }close braces end code blocks and must match an earlier open brace
213 elseelse is what happens when the if condition is false
214 {open braces start code blocks and must be matched with a close brace
215 intersecting=this assignment operator makes the left side equal to the right sidefalsefalse is a value for the boolean type and means not true;
216 }close braces end code blocks and must match an earlier open brace
217
218 }close braces end code blocks and must match an earlier open brace
219
220 /** changes color of
221 * diamonds every 5 seconds*/
222 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value changeColors()
223 {open braces start code blocks and must be matched with a close brace
224 ifif executes the next statement only if the condition in parenthesis evaluates to true(getTime()>0)
225 {open braces start code blocks and must be matched with a close brace
226 diamond.setColor(Color.RED);
227 diamond2.setColor(Color.RED);
228 }close braces end code blocks and must match an earlier open brace
229 ifif executes the next statement only if the condition in parenthesis evaluates to true(getTime()>5)
230 {open braces start code blocks and must be matched with a close brace
231 diamond.setColor(Color.GREEN);
232 diamond2.setColor(Color.GREEN);
233 }close braces end code blocks and must match an earlier open brace
234 ifif executes the next statement only if the condition in parenthesis evaluates to true(getTime()>10)
235 {open braces start code blocks and must be matched with a close brace
236 diamond.setColor(Color.ORANGE);
237 diamond2.setColor(Color.ORANGE);
238 }close braces end code blocks and must match an earlier open brace
239 ifif executes the next statement only if the condition in parenthesis evaluates to true(getTime()>15)
240 {open braces start code blocks and must be matched with a close brace
241 diamond.setColor(Color.BLUE);
242 diamond2.setColor(Color.BLUE);
243 }close braces end code blocks and must match an earlier open brace
244 ifif executes the next statement only if the condition in parenthesis evaluates to true(getTime()>20)
245 {open braces start code blocks and must be matched with a close brace
246 diamond.setColor(Color.YELLOW);
247 diamond2.setColor(Color.YELLOW);
248 }close braces end code blocks and must match an earlier open brace
249 ifif executes the next statement only if the condition in parenthesis evaluates to true(getTime()>25)
250 {open braces start code blocks and must be matched with a close brace
251 resetTime();
252 }close braces end code blocks and must match an earlier open brace
253 }close braces end code blocks and must match an earlier open brace
254
255 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addShapes()
256 {open braces start code blocks and must be matched with a close brace
257 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getMouse().getClickLocation()!=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)
258 {open braces start code blocks and must be matched with a close brace
259 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
260 ifif executes the next statement only if the condition in parenthesis evaluates to true(!this is the not operator, which changes true to false and false to truebackground.intersects(click))
261 {open braces start code blocks and must be matched with a close brace
262 polygon=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(random.nextInt(3)+adds two numbers together or concatenates Strings together3);
263 polygon.setScale(.02);
264 polygon.setLocation(getPlayer().getMouse().getClickLocation());
265 Color color=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Color(random.nextFloat(), random.nextFloat(), random.nextFloat());
266 polygon.setColor(color);
267 canvas.addSprite(polygon);
268 }close braces end code blocks and must match an earlier open brace
269 }close braces end code blocks and must match an earlier open brace
270 }close braces end code blocks and must match an earlier open brace
271
272 /**runs handleCollisions method and
273 * makes diamonds change color with time*/
274 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)
275 {open braces start code blocks and must be matched with a close brace
276 handleCollisions();
277 changeColors();
278 addShapes();
279 }close braces end code blocks and must match an earlier open brace
280 }close braces end code blocks and must match an earlier open brace
|