From ggc
|
001 packagepackage is used to name the directory or folder a class is in MattC;
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 Mcrauswe
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 Wackadot 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
015 privateprivate is used to restrict access to the current class only Sprite dot;
016
017 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
018 {open braces start code blocks and must be matched with a close brace
019 score=this assignment operator makes the left side equal to the right side0;
020 timeLeft=this assignment operator makes the left side equal to the right side10;
021 makeSprites();
022 addSprites();
023 scheduleRelative(newnew is used to create objects by calling the constructor TimeUpdater(), 1);
024 setHelp("resources/WackadotHelp.html");
025
026 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("Jam1.gif"));
027 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("Jam2.gif"));
028 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("Jam3.gif"));
029
030 }close braces end code blocks and must match an earlier open brace
031
032 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
033 {open braces start code blocks and must be matched with a close brace
034 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value alarm()
035 {open braces start code blocks and must be matched with a close brace
036 timeLeft--this is the decrement operator, which decreases the variable by 1;
037 updateTimer();
038 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
039 {open braces start code blocks and must be matched with a close brace
040 scheduleRelative(thisthis means the current object (the implicit parameter), 1);
041 }close braces end code blocks and must match an earlier open brace
042 }close braces end code blocks and must match an earlier open brace
043 }close braces end code blocks and must match an earlier open brace
044
045
046 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
047 {open braces start code blocks and must be matched with a close brace
048 Ellipse2D.Double circle=this assignment operator makes the left side equal to the right side
049 newnew is used to create objects by calling the constructor Ellipse2D.Double(0, 0, 1, 1);
050
051 dot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Jam1.jpg"));
052 dot.setScale(0.1);
053 dot.setLocation(0.5, 0.5);
054 dot.setColor(Color.RED);
055
056 redDot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Jam2.jpg"));
057 redDot.setScale(0.1);
058 redDot.setLocation(
059 random.nextDouble(),
060 random.nextDouble());
061 redDot.setColor(Color.RED);
062
063 blueDot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Jam3.jpg"));
064 blueDot.setScale(0.1);
065 blueDot.setLocation(
066 random.nextDouble(),
067 random.nextDouble());
068
069 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);
070 timerSprite.leftJustify();
071 timerSprite.topJustify();
072 timerSprite.setHeight(0.1);
073 timerSprite.setLocation(0, 0);
074
075 }close braces end code blocks and must match an earlier open brace
076
077 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
078 {open braces start code blocks and must be matched with a close brace
079 canvas.addSprite(dot);
080 canvas.addSprite(redDot);
081 canvas.addSprite(blueDot);
082 canvas.addSprite(scoreSprite);
083 canvas.addSprite(timerSprite);
084
085 }close braces end code blocks and must match an earlier open brace
086
087 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateTimer()
088 {open braces start code blocks and must be matched with a close brace
089 timerSprite.setText("Timer: "+adds two numbers together or concatenates Strings togethertimeLeft);
090 }close braces end code blocks and must match an earlier open brace
091
092
093 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)
094 {open braces start code blocks and must be matched with a close brace
095 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
096 {open braces start code blocks and must be matched with a close brace
097 Point2D.Double mouse=this assignment operator makes the left side equal to the right side
098 getPlayer().getMouse().getLocation();
099 dot.setLocation(mouse);
100 handleCollisions();
101 }close braces end code blocks and must match an earlier open brace
102 }close braces end code blocks and must match an earlier open brace
103
104 privateprivate is used to restrict access to the current class only Sprite redDot;
105 privateprivate is used to restrict access to the current class only Sprite blueDot;
106
107 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value repositionRandomly(Sprite sprite)
108 {open braces start code blocks and must be matched with a close brace
109 sprite.setLocation(
110 random.nextDouble(),
111 random.nextDouble());
112 }close braces end code blocks and must match an earlier open brace
113
114 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
115 {open braces start code blocks and must be matched with a close brace
116 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.intersects(blueDot))
117 {open braces start code blocks and must be matched with a close brace
118 repositionRandomly(blueDot);
119 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.getColor().equals(Color.BLUE))
120 {open braces start code blocks and must be matched with a close brace
121
122 dot.setColor(Color.RED);
123 score++this is the increment operator, which increases the variable by 1;
124 }close braces end code blocks and must match an earlier open brace
125 elseelse is what happens when the if condition is false
126 {open braces start code blocks and must be matched with a close brace
127 score--this is the decrement operator, which decreases the variable by 1;
128 }close braces end code blocks and must match an earlier open brace
129 updateScore();
130
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(dot.intersects(redDot))
133 {open braces start code blocks and must be matched with a close brace
134 repositionRandomly(redDot);
135 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.getColor().equals(Color.RED))
136 {open braces start code blocks and must be matched with a close brace
137 dot.setColor(Color.BLUE);
138 score++this is the increment operator, which increases the variable by 1;
139 }close braces end code blocks and must match an earlier open brace
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 }close braces end code blocks and must match an earlier open brace
144 updateScore();
145
146 }close braces end code blocks and must match an earlier open brace
147 }close braces end code blocks and must match an earlier open brace
148
149 privateprivate is used to restrict access to the current class only StringSprite scoreSprite;
150 {open braces start code blocks and must be matched with a close brace
151 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("Jam1.gif"));
152 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("Jam2.gif"));
153 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("Jam3.gif"));
154 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");
155 scoreSprite.setHeight(0.1);
156 scoreSprite.rightJustify();
157 scoreSprite.topJustify();
158 scoreSprite.setLocation(1, 0);
159 }close braces end code blocks and must match an earlier open brace
160
161 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;
162
163 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateScore()
164 {open braces start code blocks and must be matched with a close brace
165 scoreSprite.setText("Score: "+adds two numbers together or concatenates Strings togetherscore);
166 }close braces end code blocks and must match an earlier open brace
167
168 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;
169 privateprivate is used to restrict access to the current class only StringSprite timerSprite;
170
171 privateprivate is used to restrict access to the current class only ImageSprite sprite;
172
173 privateprivate is used to restrict access to the current class only Sound sound;
174
175 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSounds()
176 {open braces start code blocks and must be matched with a close brace
177 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("Sound1.wav"));
178 }close braces end code blocks and must match an earlier open brace
179 }close braces end code blocks and must match an earlier open brace
|
Compiler Errors:
----------
1. ERROR in MattC/Wackadot.java (at line 26)
sprite=new ImageSprite(Wiki.getMedia("Jam1.gif"));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
2. ERROR in MattC/Wackadot.java (at line 27)
sprite=new ImageSprite(Wiki.getMedia("Jam2.gif"));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
9 problems (9 errors)
Download/View MattC/Wackadot.java