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