|
001 packagepackage is used to name the directory or folder a class is in Charles;
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 Charles
011 */
012 /**
013 *Used Frank Andersons SineWave to get an idea of how to change the height.
014 *Used Derrick Dixon's bulls eye to help with alternating the colors.
015 */
016 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 DotPatterns extendsextends means to customize or extend the functionality of a class Game
017 {open braces start code blocks and must be matched with a close brace
018 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
019 {open braces start code blocks and must be matched with a close brace
020 makeAndShowTitlePage();
021 //makeAndShowHorizontal();
022 //makeAndShowDiagonal();
023 //makeAndShowSineWave();
024 //makeAndShowVertWave();
025 //makeAndShowSquareGrid();
026 //makeAndShowBow();
027 //makeAndShowBullsEye();
028 //makeAndShowFourBullsEyes();
029 //makeAndShowEnd();
030 }close braces end code blocks and must match an earlier open brace
031 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndShowTitlePage()
032 {open braces start code blocks and must be matched with a close brace
033 StringSprite title=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Chanelle and Charles");
034 title.setSize(.8);
035 title.setLocation(.5, .3);
036 title.setColor(Palette.getColor("Hot Pink"));
037 addSprite(title);
038
039 StringSprite title2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Dot Patterns");
040 title2.setSize(.5);
041 title2.setLocation(.5, .7);
042 title2.setColor(Palette.getColor("Hot Pink"));
043 addSprite(title2);
044
045 StringSprite title3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Use keys 1-9 to navigate.");
046 title3.setSize(.3);
047 title3.setLocation(.5, .9);
048 title3.setColor(Palette.getColor("Hot Pink"));
049 addSprite(title3);
050
051 }close braces end code blocks and must match an earlier open brace
052 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndShowEnd()
053 {open braces start code blocks and must be matched with a close brace
054 StringSprite title=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("The End");
055 title.setSize(.98);
056 title.setLocation(.5, .5);
057 title.setColor(Palette.getColor("Hot Pink"));
058 addSprite(title);
059 }close braces end code blocks and must match an earlier open brace
060 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndShowHorizontal()
061 {open braces start code blocks and must be matched with a close brace
062 intint is the type for whole numbers and it is short for integer dotsAcross=this assignment operator makes the left side equal to the right side5;
063 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<=this evaluates to true if the left side is not more than the right sidedotsAcross; i++this is the increment operator, which increases the variable by 1)
064 {open braces start code blocks and must be matched with a close brace
065 OvalSprite dot=this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(1, 1);
066 dot.setSize(0.9/dotsAcross);
067 doubledouble is the type for numbers that can contain decimal fractions x=this assignment operator makes the left side equal to the right side0.5/dotsAcross +adds two numbers together or concatenates Strings together 1.0/dotsAcross * (i-1);
068 dot.setLocation(x, .5);
069 dot.setColor(Palette.getColor("Fire Brick"));
070 addSprite(dot);
071 }close braces end code blocks and must match an earlier open brace
072
073
074 }close braces end code blocks and must match an earlier open brace
075
076 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndShowDiagonal()
077 {open braces start code blocks and must be matched with a close brace
078 intint is the type for whole numbers and it is short for integer dotsAcross=this assignment operator makes the left side equal to the right side8;
079 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<=this evaluates to true if the left side is not more than the right sidedotsAcross; i++this is the increment operator, which increases the variable by 1)
080 {open braces start code blocks and must be matched with a close brace
081 OvalSprite dot=this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(1, 1);
082 dot.setSize(0.9/dotsAcross);
083 doubledouble is the type for numbers that can contain decimal fractions x=this assignment operator makes the left side equal to the right side0.5/dotsAcross +adds two numbers together or concatenates Strings together 1.0/dotsAcross * (i-1);
084 doubledouble is the type for numbers that can contain decimal fractions y=this assignment operator makes the left side equal to the right side0.5/dotsAcross +adds two numbers together or concatenates Strings together 1.0/dotsAcross * (i-1);
085 dot.setLocation(x, y);
086 dot.setColor(Palette.getColor("Hot Pink"));
087 addSprite(dot);
088 }close braces end code blocks and must match an earlier open brace
089
090 }close braces end code blocks and must match an earlier open brace
091 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndShowSineWave()
092 {open braces start code blocks and must be matched with a close brace
093 intint is the type for whole numbers and it is short for integer dots=this assignment operator makes the left side equal to the right side60;
094 {open braces start code blocks and must be matched with a close brace
095 doubledouble is the type for numbers that can contain decimal fractions adj_h;
096 adj_h=this assignment operator makes the left side equal to the right side.3;
097 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<=this evaluates to true if the left side is not more than the right sidedots; i++this is the increment operator, which increases the variable by 1)
098 {open braces start code blocks and must be matched with a close brace
099 OvalSprite dot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
100 dot.setSize(0.6/dots);
101 doubledouble is the type for numbers that can contain decimal fractions x=this assignment operator makes the left side equal to the right side(i-1)*(1.0/dots)+adds two numbers together or concatenates Strings together1.0/(2.0*dots);
102 doubledouble is the type for numbers that can contain decimal fractions y=this assignment operator makes the left side equal to the right side.5 - adj_h*(Math.sin((i-1)*2.0*3.14/dots));
103 dot.setLocation(x,y);
104 dot.setColor(Palette.getColor("Hot Pink"));
105 addSprite(dot);
106 }close braces end code blocks and must match an earlier open brace
107 }close braces end code blocks and must match an earlier open brace
108
109 }close braces end code blocks and must match an earlier open brace
110 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndShowVertWave()
111 {open braces start code blocks and must be matched with a close brace
112 intint is the type for whole numbers and it is short for integer dots=this assignment operator makes the left side equal to the right side60;
113 {open braces start code blocks and must be matched with a close brace
114 doubledouble is the type for numbers that can contain decimal fractions adj_h;
115 adj_h=this assignment operator makes the left side equal to the right side.3;
116 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<=this evaluates to true if the left side is not more than the right sidedots; i++this is the increment operator, which increases the variable by 1)
117 {open braces start code blocks and must be matched with a close brace
118 OvalSprite dot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
119 dot.setSize(0.6/dots);
120 doubledouble is the type for numbers that can contain decimal fractions y=this assignment operator makes the left side equal to the right side(i-1)*(1.0/dots)+adds two numbers together or concatenates Strings together1.0/(2.0*dots);
121 doubledouble is the type for numbers that can contain decimal fractions x=this assignment operator makes the left side equal to the right side.5 - adj_h*(Math.sin((i-1)*2.0*3.14/dots));
122 dot.setLocation(x,y);
123 dot.setColor(Palette.getColor("Fire Brick"));
124 addSprite(dot);
125 }close braces end code blocks and must match an earlier open brace
126 }close braces end code blocks and must match an earlier open brace
127
128 }close braces end code blocks and must match an earlier open brace
129
130
131
132 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndShowSquareGrid()
133 {open braces start code blocks and must be matched with a close brace
134 intint is the type for whole numbers and it is short for integer dotsAcross=this assignment operator makes the left side equal to the right side10;
135 intint is the type for whole numbers and it is short for integer dotsDown=this assignment operator makes the left side equal to the right side10;
136 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer j=this assignment operator makes the left side equal to the right side0; j<dotsDown; j++this is the increment operator, which increases the variable by 1)
137 {open braces start code blocks and must be matched with a close brace
138 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<=this evaluates to true if the left side is not more than the right sidedotsAcross; i++this is the increment operator, which increases the variable by 1)
139 {open braces start code blocks and must be matched with a close brace
140 OvalSprite dots=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
141 dots.setSize(0.9/dotsAcross);
142 doubledouble is the type for numbers that can contain decimal fractions x=this assignment operator makes the left side equal to the right side0.5/dotsAcross+adds two numbers together or concatenates Strings together1.0/dotsAcross*(i-1);
143 doubledouble is the type for numbers that can contain decimal fractions y=this assignment operator makes the left side equal to the right side0.5/dotsAcross+adds two numbers together or concatenates Strings together(j+adds two numbers together or concatenates Strings together0.0)/dotsAcross;
144 dots.setLocation(x,y);
145 dots.setColor(Palette.getColor("Medium Blue"));
146 addSprite(dots);
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 }close braces end code blocks and must match an earlier open brace
150 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndShowBow()
151 {open braces start code blocks and must be matched with a close brace
152 OvalSprite oval1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
153 oval1.setSize(1.0);
154 oval1.setLocation(0.5,0.5);
155 oval1.setColor(Palette.getColor("Teal"));
156 addSprite(oval1);
157
158 OvalSprite oval2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
159 oval2.setSize(1.0);
160 oval2.setLocation(0.5,0.0);
161 oval2.setColor(Color.BLACK);
162 addSprite(oval2);
163
164 OvalSprite oval3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
165 oval3.setSize(1.0);
166 oval3.setLocation(0.5,1.0);
167 oval3.setColor(Color.BLACK);
168 addSprite(oval3);
169 }close braces end code blocks and must match an earlier open brace
170
171 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndShowBullsEye()
172 {open braces start code blocks and must be matched with a close brace
173 intint is the type for whole numbers and it is short for integer rings=this assignment operator makes the left side equal to the right side10;
174 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<=this evaluates to true if the left side is not more than the right siderings; i++this is the increment operator, which increases the variable by 1)
175 {open braces start code blocks and must be matched with a close brace
176 OvalSprite ring=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
177 ring.setLocation(0.5, 0.5);
178 doubledouble is the type for numbers that can contain decimal fractions s=this assignment operator makes the left side equal to the right side(0.9-(0.9*(i-1)/rings));
179 ring.setSize(s);
180 ifif executes the next statement only if the condition in parenthesis evaluates to true (i%this divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same0)
181 ring.setColor(Palette.getColor("Fire Brick"));
182 elseelse is what happens when the if condition is false
183 ring.setColor(Palette.getColor("Medium Blue"));
184 addSprite(ring);
185 }close braces end code blocks and must match an earlier open brace
186
187 }close braces end code blocks and must match an earlier open brace
188 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndShowFourBullsEyes()
189 {open braces start code blocks and must be matched with a close brace
190 intint is the type for whole numbers and it is short for integer rings1=this assignment operator makes the left side equal to the right side10;
191 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<=this evaluates to true if the left side is not more than the right siderings1; i++this is the increment operator, which increases the variable by 1)
192 {open braces start code blocks and must be matched with a close brace
193 OvalSprite bi1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
194 bi1.setLocation(0.25, 0.25);
195 doubledouble is the type for numbers that can contain decimal fractions s=this assignment operator makes the left side equal to the right side(0.5-(0.5*(i-1)/rings1));
196 bi1.setSize(s);
197 ifif executes the next statement only if the condition in parenthesis evaluates to true (i%this divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same0)
198 bi1.setColor(Palette.getColor("Fire Brick"));
199 elseelse is what happens when the if condition is false
200 bi1.setColor(Palette.getColor("Medium Blue"));
201 addSprite(bi1);
202 }close braces end code blocks and must match an earlier open brace
203 intint is the type for whole numbers and it is short for integer rings2=this assignment operator makes the left side equal to the right side10;
204 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<=this evaluates to true if the left side is not more than the right siderings2; i++this is the increment operator, which increases the variable by 1)
205 {open braces start code blocks and must be matched with a close brace
206 OvalSprite bi2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
207 bi2.setLocation(0.75, 0.25);
208 doubledouble is the type for numbers that can contain decimal fractions s=this assignment operator makes the left side equal to the right side(0.5-(0.5*(i-1)/rings2));
209 bi2.setSize(s);
210 ifif executes the next statement only if the condition in parenthesis evaluates to true (i%this divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same0)
211 bi2.setColor(Palette.getColor("Fire Brick"));
212 elseelse is what happens when the if condition is false
213 bi2.setColor(Palette.getColor("Medium Blue"));
214 addSprite(bi2);
215 }close braces end code blocks and must match an earlier open brace
216 intint is the type for whole numbers and it is short for integer rings3=this assignment operator makes the left side equal to the right side10;
217 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<=this evaluates to true if the left side is not more than the right siderings3; i++this is the increment operator, which increases the variable by 1)
218 {open braces start code blocks and must be matched with a close brace
219 OvalSprite bi3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
220 bi3.setLocation(0.25, 0.75);
221 doubledouble is the type for numbers that can contain decimal fractions s=this assignment operator makes the left side equal to the right side(0.5-(0.5*(i-1)/rings3));
222 bi3.setSize(s);
223 ifif executes the next statement only if the condition in parenthesis evaluates to true (i%this divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same0)
224 bi3.setColor(Palette.getColor("Fire Brick"));
225 elseelse is what happens when the if condition is false
226 bi3.setColor(Palette.getColor("Medium Blue"));
227 addSprite(bi3);
228 }close braces end code blocks and must match an earlier open brace
229 intint is the type for whole numbers and it is short for integer rings4=this assignment operator makes the left side equal to the right side10;
230 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<=this evaluates to true if the left side is not more than the right siderings4; i++this is the increment operator, which increases the variable by 1)
231 {open braces start code blocks and must be matched with a close brace
232 OvalSprite bi4=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
233 bi4.setLocation(0.75, 0.75);
234 doubledouble is the type for numbers that can contain decimal fractions s=this assignment operator makes the left side equal to the right side(0.5-(0.5*(i-1)/rings4));
235 bi4.setSize(s);
236 ifif executes the next statement only if the condition in parenthesis evaluates to true (i%this divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same0)
237 bi4.setColor(Palette.getColor("Fire Brick"));
238 elseelse is what happens when the if condition is false
239 bi4.setColor(Palette.getColor("Medium Blue"));
240 addSprite(bi4);
241 }close braces end code blocks and must match an earlier open brace
242
243 }close braces end code blocks and must match an earlier open brace
244
245 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
246 {open braces start code blocks and must be matched with a close brace
247 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'7')
248 {open braces start code blocks and must be matched with a close brace
249 removeAllSprites();
250 makeAndShowBullsEye();
251 }close braces end code blocks and must match an earlier open brace
252 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'5')
253 {open braces start code blocks and must be matched with a close brace
254 removeAllSprites();
255 makeAndShowSquareGrid();
256 }close braces end code blocks and must match an earlier open brace
257 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'6')
258 {open braces start code blocks and must be matched with a close brace
259 removeAllSprites();
260 makeAndShowBow();
261 }close braces end code blocks and must match an earlier open brace
262 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'1')
263 {open braces start code blocks and must be matched with a close brace
264 removeAllSprites();
265 makeAndShowHorizontal();
266 }close braces end code blocks and must match an earlier open brace
267 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'2')
268 {open braces start code blocks and must be matched with a close brace
269 removeAllSprites();
270 makeAndShowDiagonal();
271 }close braces end code blocks and must match an earlier open brace
272 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'3')
273 {open braces start code blocks and must be matched with a close brace
274 removeAllSprites();
275 makeAndShowSineWave();
276 }close braces end code blocks and must match an earlier open brace
277 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'4')
278 {open braces start code blocks and must be matched with a close brace
279 removeAllSprites();
280 makeAndShowVertWave();
281 }close braces end code blocks and must match an earlier open brace
282 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'8')
283 {open braces start code blocks and must be matched with a close brace
284 removeAllSprites();
285 makeAndShowFourBullsEyes();
286 }close braces end code blocks and must match an earlier open brace
287 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'9')
288 {open braces start code blocks and must be matched with a close brace
289 removeAllSprites();
290 makeAndShowEnd();
291 }close braces end code blocks and must match an earlier open brace
292 }close braces end code blocks and must match an earlier open brace
293
294 }close braces end code blocks and must match an earlier open brace
|