|
001 packagepackage is used to name the directory or folder a class is in KMM;
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 * @authornull Kim, Merima, Matt
011 */
012 /**This is a fun, simple game I made using
013 * the FANG Engine.
014 * @authornull Kim, Merima, Matt
015 */
016
017 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 FinalProject extendsextends means to customize or extend the functionality of a class GameLoop
018
019 {open braces start code blocks and must be matched with a close brace
020 privateprivate is used to restrict access to the current class only Sprite lBorder, rBorder, tBorder, bBorder;
021 privateprivate is used to restrict access to the current class only Sprite picture1, picture2, picture3;
022 privateprivate is used to restrict access to the current class only StringSprite scoreSprite, timerSprite, message1Sprite, message2Sprite;
023 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer score, timeLeft;
024 privateprivate is used to restrict access to the current class only ImageSprite sprite;
025 privateprivate is used to restrict access to the current class only OutlineTracker tracker;
026 privateprivate is used to restrict access to the current class only ProjectileTracker track;
027 privateprivate is used to restrict access to the current class only Sound sound;
028
029
030 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
031 {open braces start code blocks and must be matched with a close brace
032 score=this assignment operator makes the left side equal to the right side0;
033 timeLeft=this assignment operator makes the left side equal to the right side60;
034 makeSound();
035 makeWalls();
036 makeGlamorShots();
037 makeScoreAndTimer();
038 makeSpinningWords();
039 setupAlarm( 1 );
040 scheduleRelative(newnew is used to create objects by calling the constructor TimeUpdater(), 1);
041 setHelpText("Welcome to wackadot 2000! Same rules for the original apply, only now you just need to party hard and don't go blind. Oh yeah!!!!");
042 toggleAudible();
043
044 }close braces end code blocks and must match an earlier open brace
045 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSound()
046 {open braces start code blocks and must be matched with a close brace
047 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("Beep1.wav"));
048
049 }close braces end code blocks and must match an earlier open brace
050
051 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeWalls()
052 {open braces start code blocks and must be matched with a close brace
053 lBorder=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(40, 40);
054 lBorder.setLocation(0.015, 0.5);
055 lBorder.setScale(1);
056 lBorder.setColor(Color.RED);
057 canvas.addSprite(lBorder);
058
059 rBorder=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(40, 40);
060 rBorder.setLocation(.985, 0.5);
061 rBorder.setScale(1);
062 rBorder.setColor(Color.RED);
063 canvas.addSprite(rBorder);
064
065 tBorder=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(40, 40);
066 tBorder.setLocation(0.5, 0);
067 tBorder.setScale(1);
068 tBorder.setColor(Color.RED);
069 canvas.addSprite(tBorder);
070
071 bBorder=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(40, 40);
072 bBorder.setLocation(0.5, 1);
073 bBorder.setScale(1);
074 bBorder.setColor(Color.RED);
075 canvas.addSprite(bBorder);
076 }close braces end code blocks and must match an earlier open brace
077 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value randomColorBound()
078 {open braces start code blocks and must be matched with a close brace
079 lBorder.setColor(newnew is used to create objects by calling the constructor Color(random.nextInt()));
080 rBorder.setColor(newnew is used to create objects by calling the constructor Color(random.nextInt()));
081 tBorder.setColor(newnew is used to create objects by calling the constructor Color(random.nextInt()));
082 bBorder.setColor(newnew is used to create objects by calling the constructor Color(random.nextInt()));
083 }close braces end code blocks and must match an earlier open brace
084
085 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeGlamorShots()
086 {open braces start code blocks and must be matched with a close brace
087 sprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Kimberly.gif"));
088 sprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Merima.gif"));
089 sprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Matthew.gif"));
090 Ellipse2D.Double circle=this assignment operator makes the left side equal to the right side
091 newnew is used to create objects by calling the constructor Ellipse2D.Double(0, 0, 1, 1);
092
093 picture1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Kimberly.gif"));
094 picture1.setScale(0.25);
095 picture1.setLocation(0.5, 0.5);
096 picture1.setColor(Color.RED);
097 canvas.addSprite(picture1);
098
099 picture2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Merima.gif"));
100 picture2.setScale(0.25);
101 picture2.setLocation(
102 random.nextDouble(),
103 random.nextDouble());
104 picture2.setColor(Color.RED);
105 canvas.addSprite(picture2);
106
107 picture3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Matthew.gif"));
108 picture3.setScale(0.25);
109 picture3.setLocation(
110 random.nextDouble(),
111 random.nextDouble());
112 picture3.setColor(Color.BLUE);
113 canvas.addSprite(picture3);
114 }close braces end code blocks and must match an earlier open brace
115 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeScoreAndTimer()
116 {open braces start code blocks and must be matched with a close brace
117
118 scoreSprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Score: 0");
119 scoreSprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Score: "+adds two numbers together or concatenates Strings togetherscore);
120 scoreSprite.setHeight(0.1);
121 scoreSprite.rightJustify();
122 scoreSprite.topJustify();
123 scoreSprite.setLocation(1, 0);
124 canvas.addSprite(scoreSprite);
125
126 timerSprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Timer: "+adds two numbers together or concatenates Strings togethertimeLeft);
127 timerSprite.leftJustify();
128 timerSprite.topJustify();
129 timerSprite.setHeight(0.1);
130 timerSprite.setLocation(0, 0);
131 canvas.addSprite(timerSprite);
132 }close braces end code blocks and must match an earlier open brace
133 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSpinningWords()
134 {open braces start code blocks and must be matched with a close brace
135 message1Sprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Welcome to our rave!");
136 message1Sprite.setHeight(0.08);
137 message1Sprite.setLocation(.5, .5);
138 message1Sprite.setColor(Color.RED);
139 canvas.addSprite(message1Sprite);
140
141 message2Sprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Now lets Party!!!!");
142 message2Sprite.setHeight(0.08);
143 message2Sprite.setLocation(.5, .75);
144 message2Sprite.setColor(Color.GREEN);
145 canvas.addSprite(message2Sprite);
146
147 /**make the picture and words rotate*/
148 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);
149 track=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(direction);
150 /**rotate 1/2 a revolution per second*/
151 track.setAngularVelocity(10);
152 picture3.setTracker(track);
153 message1Sprite.setTracker(track);
154 message2Sprite.setTracker(track);
155 }close braces end code blocks and must match an earlier open brace
156
157 classclass is a group of fields and methods used for making objects TimeUpdater implementsimplements means providing method bodies for the methods declared in the corresponding interface Alarm
158 {open braces start code blocks and must be matched with a close brace
159 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value alarm()
160 {open braces start code blocks and must be matched with a close brace
161 timeLeft--this is the decrement operator, which decreases the variable by 1;
162 updateTimer();
163 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
164 {open braces start code blocks and must be matched with a close brace
165 scheduleRelative(thisthis means the current object (the implicit parameter), 1);
166 }close braces end code blocks and must match an earlier open brace
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
170
171 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateTimer()
172 {open braces start code blocks and must be matched with a close brace
173 timerSprite.setText("Timer: "+adds two numbers together or concatenates Strings togethertimeLeft);
174 }close braces end code blocks and must match an earlier open brace
175
176 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value repositionRandomly(Sprite sprite)
177 {open braces start code blocks and must be matched with a close brace
178 sprite.setLocation(
179 random.nextDouble(),
180 random.nextDouble());
181 }close braces end code blocks and must match an earlier open brace
182
183 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateScore()
184 {open braces start code blocks and must be matched with a close brace
185 scoreSprite.setText("Score: "+adds two numbers together or concatenates Strings togetherscore);
186 }close braces end code blocks and must match an earlier open brace
187
188 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
189 {open braces start code blocks and must be matched with a close brace
190 ifif executes the next statement only if the condition in parenthesis evaluates to true(picture1.intersects(picture3))
191 {open braces start code blocks and must be matched with a close brace
192 repositionRandomly(picture3);
193 ifif executes the next statement only if the condition in parenthesis evaluates to true(picture1.getColor().equals(Color.BLUE))
194 {open braces start code blocks and must be matched with a close brace
195 picture1.setColor(Color.RED);
196 score++this is the increment operator, which increases the variable by 1;
197 sound.play();
198
199 }close braces end code blocks and must match an earlier open brace
200 elseelse is what happens when the if condition is false
201 {open braces start code blocks and must be matched with a close brace
202 score--this is the decrement operator, which decreases the variable by 1;
203 sound.play();
204
205 }close braces end code blocks and must match an earlier open brace
206 updateScore();
207 }close braces end code blocks and must match an earlier open brace
208 ifif executes the next statement only if the condition in parenthesis evaluates to true(picture1.intersects(picture2))
209 {open braces start code blocks and must be matched with a close brace
210 repositionRandomly(picture2);
211 ifif executes the next statement only if the condition in parenthesis evaluates to true(picture1.getColor().equals(Color.RED))
212 {open braces start code blocks and must be matched with a close brace
213 picture1.setColor(Color.BLUE);
214 score++this is the increment operator, which increases the variable by 1;
215 sound.play();
216
217 }close braces end code blocks and must match an earlier open brace
218 elseelse is what happens when the if condition is false
219 {open braces start code blocks and must be matched with a close brace
220 score--this is the decrement operator, which decreases the variable by 1;
221 sound.play();
222 }close braces end code blocks and must match an earlier open brace
223 updateScore();
224 }close braces end code blocks and must match an earlier open brace
225 }close braces end code blocks and must match an earlier open brace
226 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)
227 {open braces start code blocks and must be matched with a close brace
228 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
229 {open braces start code blocks and must be matched with a close brace
230 Point2D.Double mouse=this assignment operator makes the left side equal to the right side
231 getPlayer().getMouse().getLocation();
232 picture1.setLocation(mouse);
233 handleCollisions();
234 toggleAudible();
235 }close braces end code blocks and must match an earlier open brace
236
237 randomColorBound();
238 }close braces end code blocks and must match an earlier open brace
239
240 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value setupAlarm( doubledouble is the type for numbers that can contain decimal fractions time )
241 {open braces start code blocks and must be matched with a close brace
242 scheduleRelative(newnew is used to create objects by calling the constructor MyAlarm( ), time ) ;
243 }close braces end code blocks and must match an earlier open brace
244
245 privateprivate is used to restrict access to the current class only classclass is a group of fields and methods used for making objects MyAlarm implementsimplements means providing method bodies for the methods declared in the corresponding interface Alarm
246 {open braces start code blocks and must be matched with a close brace
247 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value alarm( )
248 {open braces start code blocks and must be matched with a close brace
249 picture2.setVisible( !this is the not operator, which changes true to false and false to truepicture2.isVisible( ) ) ;
250 scheduleRelative( thisthis means the current object (the implicit parameter), 2 ) ;
251 }close braces end code blocks and must match an earlier open brace
252 }close braces end code blocks and must match an earlier open brace
253
254 }close braces end code blocks and must match an earlier open brace
|