From ggc
|
001 packagepackage is used to name the directory or folder a class is in GBell.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 /**This is a simple game I made that is modified from the basic Wackadot.
009 * @authornull Gbell
010 */
011 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
012 {open braces start code blocks and must be matched with a close brace
013 privateprivate is used to restrict access to the current class only Sprite dot;
014 privateprivate is used to restrict access to the current class only ImageSprite redsmile;
015 privateprivate is used to restrict access to the current class only ImageSprite bluesmile;
016 privateprivate is used to restrict access to the current class only StringSprite scoreSprite;
017 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;
018 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;
019 privateprivate is used to restrict access to the current class only StringSprite timerSprite;
020 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("Other.wav"));
021 privateprivate is used to restrict access to the current class only Sound sound2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Pluck.wav"));
022
023 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
024 {open braces start code blocks and must be matched with a close brace
025 score=this assignment operator makes the left side equal to the right side0;
026 timeLeft=this assignment operator makes the left side equal to the right side10;
027 makeSprites();
028 addSprites();
029 scheduleRelative(newnew is used to create objects by calling the constructor TimeUpdater(), 1);
030 setHelp("resources/GbellWackadotHelp.html");
031 toggleAudible();
032 }close braces end code blocks and must match an earlier open brace
033
034 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
035 {open braces start code blocks and must be matched with a close brace
036 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value alarm()
037 {open braces start code blocks and must be matched with a close brace
038 timeLeft--this is the decrement operator, which decreases the variable by 1;
039 updateTimer();
040 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
041 {open braces start code blocks and must be matched with a close brace
042 scheduleRelative(thisthis means the current object (the implicit parameter), 1);
043 }close braces end code blocks and must match an earlier open brace
044 }close braces end code blocks and must match an earlier open brace
045 }close braces end code blocks and must match an earlier open brace
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 Sprite(circle);
052 dot.setScale(0.1);
053 dot.setLocation(0.5, 0.5);
054 dot.setColor(Color.RED);
055
056 redsmile=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Gbellredsmile.gif"));
057 redsmile.setScale(0.1);
058 redsmile.setLocation(
059 random.nextDouble(),
060 random.nextDouble());
061
062 bluesmile=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Gbellbluesmile.gif"));
063 bluesmile.setScale(0.1);
064 bluesmile.setLocation(
065 random.nextDouble(),
066 random.nextDouble());
067
068 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);
069 scoreSprite.setHeight(0.1);
070 scoreSprite.rightJustify();
071 scoreSprite.setColor(Color.YELLOW);
072 scoreSprite.topJustify();
073 scoreSprite.setLocation(1, 0);
074
075 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);
076 timerSprite.leftJustify();
077 timerSprite.topJustify();
078 timerSprite.setHeight(0.1);
079 timerSprite.setLocation(0, 0);
080
081 }close braces end code blocks and must match an earlier open brace
082
083 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateScore()
084 {open braces start code blocks and must be matched with a close brace
085 scoreSprite.setText("Score: "+adds two numbers together or concatenates Strings togetherscore);
086 }close braces end code blocks and must match an earlier open brace
087
088 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
089 {open braces start code blocks and must be matched with a close brace
090 canvas.addSprite(dot);
091 canvas.addSprite(redsmile);
092 canvas.addSprite(bluesmile);
093 canvas.addSprite(scoreSprite);
094 canvas.addSprite(timerSprite);
095 }close braces end code blocks and must match an earlier open brace
096 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateTimer()
097 {open braces start code blocks and must be matched with a close brace
098 timerSprite.setText("Timer: "+adds two numbers together or concatenates Strings togethertimeLeft);
099 }close braces end code blocks and must match an earlier open brace
100 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value repositionRandomly(Sprite sprite)
101 {open braces start code blocks and must be matched with a close brace
102 sprite.setLocation(
103 random.nextDouble(),
104 random.nextDouble());
105 }close braces end code blocks and must match an earlier open brace
106
107 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
108 {open braces start code blocks and must be matched with a close brace
109 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.intersects(bluesmile))
110 {open braces start code blocks and must be matched with a close brace
111 repositionRandomly(bluesmile);
112 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.getColor().equals(Color.BLUE))
113 {open braces start code blocks and must be matched with a close brace
114 dot.setColor(Color.RED);
115 score++this is the increment operator, which increases the variable by 1;
116 sound1.play();
117 }close braces end code blocks and must match an earlier open brace
118 elseelse is what happens when the if condition is false
119 {open braces start code blocks and must be matched with a close brace
120 score--this is the decrement operator, which decreases the variable by 1;
121 sound2.play();
122 }close braces end code blocks and must match an earlier open brace
123 updateScore();
124 }close braces end code blocks and must match an earlier open brace
125 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.intersects(redsmile))
126 {open braces start code blocks and must be matched with a close brace
127 repositionRandomly(redsmile);
128 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.getColor().equals(Color.RED))
129 {open braces start code blocks and must be matched with a close brace
130 dot.setColor(Color.BLUE);
131 score++this is the increment operator, which increases the variable by 1;
132 sound1.play();
133 }close braces end code blocks and must match an earlier open brace
134 elseelse is what happens when the if condition is false
135 {open braces start code blocks and must be matched with a close brace
136 score--this is the decrement operator, which decreases the variable by 1;
137 sound2.play();
138 }close braces end code blocks and must match an earlier open brace
139 updateScore();
140 }close braces end code blocks and must match an earlier open brace
141 }close braces end code blocks and must match an earlier open brace
142
143 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)
144 {open braces start code blocks and must be matched with a close brace
145 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
146 {open braces start code blocks and must be matched with a close brace
147 Point2D.Double mouse=this assignment operator makes the left side equal to the right side
148 getPlayer().getMouse().getLocation();
149 dot.setLocation(mouse);
150 handleCollisions();
151 }close braces end code blocks and must match an earlier open brace
152 }close braces end code blocks and must match an earlier open brace
153
154 }close braces end code blocks and must match an earlier open brace
155
156
|
Compiler Errors:
----------
1. ERROR in GBell/wackadot/Wackadot.java (at line 56)
redsmile=new ImageSprite(Wiki.getMedia("Gbellredsmile.gif"));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
2. ERROR in GBell/wackadot/Wackadot.java (at line 62)
bluesmile=new ImageSprite(Wiki.getMedia("Gbellbluesmile.gif"));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
2 problems (2 errors)
Download/View GBell/wackadot/Wackadot.java