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