From ggc
|
001
002
003 packagepackage is used to name the directory or folder a class is in ChrisHull.wackadot;
004
005 importimport means to make the classes and/or packages available in this program wiki.Wiki;
006 importimport means to make the classes and/or packages available in this program fang.*;
007 /**This is a fun, simple game I made using
008 * the FANG Engine.
009 *This game is based upon the Original Wackadot
010 *This program gave me many headaches hope you enjoy.
011 * @authorthis is the Javadoc tag for documenting who created the source code Chris Hull
012 */
013 importimport means to make the classes and/or packages available in this program java.awt.*;
014 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
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 Wackadot extendsextends means to customize or extend the functionality of a class GameLoop
017 {open braces start code blocks and must be matched with a close brace
018 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value repositionRandomly(Sprite sprite)
019 {open braces start code blocks and must be matched with a close brace
020 sprite.setLocation(
021 random.nextDouble(),
022 random.nextDouble());
023 }close braces end code blocks and must match an earlier open brace
024
025 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
026 {open braces start code blocks and must be matched with a close brace
027 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.intersects(blueDot))
028 {open braces start code blocks and must be matched with a close brace
029 repositionRandomly(blueDot);
030 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.getColor().equals(Color.BLUE))
031 {open braces start code blocks and must be matched with a close brace
032 dot.setColor(Color.RED);
033 score++this is the increment operator, which increases the variable by 1;
034 goodsound.play();
035 }close braces end code blocks and must match an earlier open brace
036 elseelse is what happens when the if condition is false
037 {open braces start code blocks and must be matched with a close brace
038 score--this is the decrement operator, which decreases the variable by 1;
039 badsound.play();
040 }close braces end code blocks and must match an earlier open brace
041 updateScore();
042 }close braces end code blocks and must match an earlier open brace
043 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.intersects(redDot))
044 {open braces start code blocks and must be matched with a close brace
045 repositionRandomly(redDot);
046 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.getColor().equals(Color.RED))
047 {open braces start code blocks and must be matched with a close brace
048 dot.setColor(Color.BLUE);
049 score++this is the increment operator, which increases the variable by 1;
050 goodsound.play();
051 }close braces end code blocks and must match an earlier open brace
052 {open braces start code blocks and must be matched with a close brace
053 score--this is the decrement operator, which decreases the variable by 1;
054 badsound.play();
055 }close braces end code blocks and must match an earlier open brace
056 updateScore();
057
058 }close braces end code blocks and must match an earlier open brace
059 }close braces end code blocks and must match an earlier open brace
060
061
062 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)
063 {open braces start code blocks and must be matched with a close brace
064 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
065 {open braces start code blocks and must be matched with a close brace
066 Point2D.Double mouse=this assignment operator makes the left side equal to the right side
067 getPlayer().getMouse().getLocation();
068 dot.setLocation(mouse);
069 handleCollisions();
070 }close braces end code blocks and must match an earlier open brace
071 }close braces end code blocks and must match an earlier open brace
072 privateprivate is used to restrict access to the current class only Sprite dot;
073 privateprivate is used to restrict access to the current class only Sprite redDot;
074 privateprivate is used to restrict access to the current class only Sprite blueDot;
075 privateprivate is used to restrict access to the current class only Sound goodsound;
076 privateprivate is used to restrict access to the current class only Sound badsound;
077 privateprivate is used to restrict access to the current class only StringSprite scoreSprite;
078 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;
079 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;
080 privateprivate is used to restrict access to the current class only StringSprite timerSprite;
081
082
083 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
084
085 {open braces start code blocks and must be matched with a close brace
086 toggleAudible();
087 score=this assignment operator makes the left side equal to the right side0;
088 timeLeft=this assignment operator makes the left side equal to the right side10;
089 makeSprites();
090 addSprites();
091 scheduleRelative(newnew is used to create objects by calling the constructor TimeUpdater(), 1);
092 setHelp("resources/WackadotHelp.html");
093 }close braces end code blocks and must match an earlier open brace
094 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
095 {open braces start code blocks and must be matched with a close brace
096 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value alarm()
097 {open braces start code blocks and must be matched with a close brace
098 timeLeft--this is the decrement operator, which decreases the variable by 1;
099 updateTimer();
100 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
101 {open braces start code blocks and must be matched with a close brace
102 scheduleRelative(thisthis means the current object (the implicit parameter), 1);
103 }close braces end code blocks and must match an earlier open brace
104 }close braces end code blocks and must match an earlier open brace
105 }close braces end code blocks and must match an earlier open brace
106 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
107 {open braces start code blocks and must be matched with a close brace
108 goodsound =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Clap.wav"));
109 badsound =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Boom.wav"));
110
111 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);
112 dot.setScale(0.1);
113 dot.setLocation(0.5, 0.5);
114 dot.setColor(Color.RED);
115
116 {open braces start code blocks and must be matched with a close brace
117 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("Red.JPG"));
118 redDot.setScale(0.1);
119 redDot.setLocation(
120 random.nextDouble(),
121 random.nextDouble());
122 redDot.setColor(Color.RED);
123
124 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("Blue.JPG"));
125 blueDot.setScale(0.1);
126 blueDot.setLocation(
127 random.nextDouble(),
128 random.nextDouble());
129
130 blueDot.setColor(Color.BLUE);
131 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");
132 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);
133 scoreSprite.setHeight(0.1);
134 scoreSprite.rightJustify();
135 scoreSprite.topJustify();
136 scoreSprite.setLocation(1, 0);
137 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);
138 timerSprite.leftJustify();
139 timerSprite.topJustify();
140 timerSprite.setHeight(0.1);
141 timerSprite.setLocation(0, 0);
142 }close braces end code blocks and must match an earlier open brace
143 }close braces end code blocks and must match an earlier open brace
144 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateScore()
145 {open braces start code blocks and must be matched with a close brace
146 scoreSprite.setText("Score: "+adds two numbers together or concatenates Strings togetherscore);
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 voidvoid means the method does not return a value addSprites()
150 {open braces start code blocks and must be matched with a close brace
151 canvas.addSprite(dot);
152 canvas.addSprite(redDot);
153 canvas.addSprite(blueDot);
154 canvas.addSprite(scoreSprite);
155 canvas.addSprite(timerSprite);
156 }close braces end code blocks and must match an earlier open brace
157 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateTimer()
158 {open braces start code blocks and must be matched with a close brace
159 timerSprite.setText("Timer: "+adds two numbers together or concatenates Strings togethertimeLeft);
160 }close braces end code blocks and must match an earlier open brace
161 ;
162 }close braces end code blocks and must match an earlier open brace
|
Compiler Errors:
----------
1. ERROR in ChrisHull/wackadot/Wackadot.java (at line 117)
redDot=new ImageSprite(Wiki.getMedia("Red.JPG"));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
2. ERROR in ChrisHull/wackadot/Wackadot.java (at line 124)
blueDot=new ImageSprite(Wiki.getMedia("Blue.JPG"));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
2 problems (2 errors)
Download/View ChrisHull/wackadot/Wackadot.java