|
001 packagepackage is used to name the directory or folder a class is in JacobOlson.wackadot;
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 * thisthis means the current object (the implicit parameter) game is very basic but yet it is a great time spender
010 * thisthis means the current object (the implicit parameter) is a duplication of an original
011 * I used the Fang Engine
012 * @authorthis is the Javadoc tag for documenting who created the source code Jacob Olson
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 Wackadot 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 privateprivate is used to restrict access to the current class only Sprite dot;
017 privateprivate is used to restrict access to the current class only Sprite redDot;
018 privateprivate is used to restrict access to the current class only Sprite blueDot;
019 privateprivate is used to restrict access to the current class only StringSprite scoreSprite;
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 score;
021 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer timeLeft;
022 privateprivate is used to restrict access to the current class only StringSprite timerSprite;
023 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("Boom1.wav"));
024 privateprivate is used to restrict access to the current class only Sound sound1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Ding.wav"));
025 privateprivate is used to restrict access to the current class only ImageSprite sprite;
026 /**
027 * thisthis means the current object (the implicit parameter) is what appears at the beginning of the game before you start
028 */
029 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
030 {open braces start code blocks and must be matched with a close brace
031 score=this assignment operator makes the left side equal to the right side0;
032 timeLeft=this assignment operator makes the left side equal to the right side30;
033 makeSprites();
034 addSprites();
035 scheduleRelative(newnew is used to create objects by calling the constructor TimeUpdater(), 1);
036 setHelp("resources/WackadotHelp.html");
037 toggleAudible();
038
039 }close braces end code blocks and must match an earlier open brace
040 /**
041 * thisthis means the current object (the implicit parameter) is wear i set up the count down forfor is a looping structure for repeatedly executing a block of code the timer during the game
042 */
043 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
044 {open braces start code blocks and must be matched with a close brace
045 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value alarm()
046 {open braces start code blocks and must be matched with a close brace
047 timeLeft--this is the decrement operator, which decreases the variable by 1;
048 updateTimer();
049 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
050 {open braces start code blocks and must be matched with a close brace
051 scheduleRelative(thisthis means the current object (the implicit parameter), 1);
052 }close braces end code blocks and must match an earlier open brace
053 }close braces end code blocks and must match an earlier open brace
054 }close braces end code blocks and must match an earlier open brace
055
056 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
057 {open braces start code blocks and must be matched with a close brace
058 Ellipse2D.Double circle=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Ellipse2D.Double(0,0,1,1);
059 dot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sprite(circle);
060 dot.setScale(0.1);
061 dot.setLocation(0.5,0.5);
062 dot.setColor(Color.RED);
063
064 redDot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
065 redDot.setScale(0.1)
066 ;
067 redDot.setLocation(
068 random.nextDouble(),
069 random.nextDouble());
070 redDot.setColor(Color.RED);
071
072 blueDot=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 blueDot.setScale(0.1);
074 blueDot.setLocation(
075 random.nextDouble(),
076 random.nextDouble());
077 blueDot.setColor(Color.BLUE);
078
079 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);
080 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");
081 scoreSprite.setHeight(0.1);
082 scoreSprite.rightJustify();
083 scoreSprite.topJustify();
084 scoreSprite.setLocation(1, 0);
085 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);
086 timerSprite.leftJustify();
087 timerSprite.topJustify();
088 timerSprite.setHeight(0.1);
089 timerSprite.setLocation(0, 0);
090
091 /**
092 *I got thisthis means the current object (the implicit parameter) picture from "http://www.flickr.com/photos/8003170@N06/481435956/"
093 */
094 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("Mountains.jpg"));
095 sprite.setScale(.8);
096 sprite.setLocation(.5,.5);
097
098 }close braces end code blocks and must match an earlier open brace
099
100 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateTimer()
101 {open braces start code blocks and must be matched with a close brace
102 timerSprite.setText("Timer: "+adds two numbers together or concatenates Strings togethertimeLeft);
103 }close braces end code blocks and must match an earlier open brace
104
105 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
106 {open braces start code blocks and must be matched with a close brace
107 canvas.addSprite(sprite);
108 canvas.addSprite(dot);
109 canvas.addSprite(redDot);
110 canvas.addSprite(blueDot);
111 canvas.addSprite(scoreSprite);
112 canvas.addSprite(timerSprite);
113
114 }close braces end code blocks and must match an earlier open brace
115
116 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value repositionRandomly(Sprite sprite)
117 {open braces start code blocks and must be matched with a close brace
118 sprite.setLocation(
119 random.nextDouble(),
120 random.nextDouble());
121 }close braces end code blocks and must match an earlier open brace
122
123 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateScore()
124 {open braces start code blocks and must be matched with a close brace
125 scoreSprite.setText("Score: "+adds two numbers together or concatenates Strings togetherscore);
126 }close braces end code blocks and must match an earlier open brace
127
128 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
129 {open braces start code blocks and must be matched with a close brace
130 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.intersects(redDot))
131 {open braces start code blocks and must be matched with a close brace
132 repositionRandomly(redDot);
133 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.getColor().equals(Color.RED))
134 {open braces start code blocks and must be matched with a close brace
135 dot.setColor(Color.BLUE);
136 score++this is the increment operator, which increases the variable by 1;
137 sound1.play();
138 }close braces end code blocks and must match an earlier open brace
139
140 elseelse is what happens when the if condition is false
141 {open braces start code blocks and must be matched with a close brace
142 score--this is the decrement operator, which decreases the variable by 1;
143 sound.play();
144 }close braces end code blocks and must match an earlier open brace
145 updateScore();
146
147 }close braces end code blocks and must match an earlier open brace
148
149 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.intersects(blueDot))
150 {open braces start code blocks and must be matched with a close brace
151 repositionRandomly(blueDot);
152 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.getColor().equals(Color.BLUE))
153 {open braces start code blocks and must be matched with a close brace
154 dot.setColor(Color.RED);
155 score++this is the increment operator, which increases the variable by 1;
156 sound1.play();
157 }close braces end code blocks and must match an earlier open brace
158
159 elseelse is what happens when the if condition is false
160 {open braces start code blocks and must be matched with a close brace
161 score--this is the decrement operator, which decreases the variable by 1;
162 sound.play();
163 }close braces end code blocks and must match an earlier open brace
164 updateScore();
165 }close braces end code blocks and must match an earlier open brace
166 }close braces end code blocks and must match an earlier open brace
167
168 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)
169 {open braces start code blocks and must be matched with a close brace
170 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
171 {open braces start code blocks and must be matched with a close brace
172 Point2D.Double mouse=this assignment operator makes the left side equal to the right side
173 getPlayer(0).getMouse().getLocation();
174 dot.setLocation(mouse);
175 handleCollisions();
176 }close braces end code blocks and must match an earlier open brace
177 }close braces end code blocks and must match an earlier open brace
178 }close braces end code blocks and must match an earlier open brace
|