From ggc
|
001 packagepackage is used to name the directory or folder a class is in Abbie.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 * @authorthis is the Javadoc tag for documenting who created the source code Abbie Lyday
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 privateprivate is used to restrict access to the current class only ImageSprite dot;
015 privateprivate is used to restrict access to the current class only ImageSprite redDot;
016 privateprivate is used to restrict access to the current class only ImageSprite blueDot;
017 privateprivate is used to restrict access to the current class only StringSprite scoreSprite;
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 score;
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 timeLeft;
020 privateprivate is used to restrict access to the current class only StringSprite timerSprite;
021 privateprivate is used to restrict access to the current class only Sound sound=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound("Grizzlybear.wav");
022 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("DingLower.wav");
023
024 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
025 {open braces start code blocks and must be matched with a close brace
026
027 score=this assignment operator makes the left side equal to the right side0;
028 timeLeft=this assignment operator makes the left side equal to the right side10;
029 makeSprites();
030
031 addSprites();
032 scheduleRelative(newnew is used to create objects by calling the constructor TimeUpdater(),1);
033 setHelpText("Use the pawprint that follows your mouse to knock into the other pictures. Match the pointer picture to another picture, and bump the match. Your pointer picture will then change, and you have to find another match to your pointer picture. Matched bumps will earn you points, while unmatched bumps will subtract points. Get as much points as possible in 10 seconds.");
034 }close braces end code blocks and must match an earlier open brace
035
036 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
037 {open braces start code blocks and must be matched with a close brace
038 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value alarm()
039 {open braces start code blocks and must be matched with a close brace
040 timeLeft--this is the decrement operator, which decreases the variable by 1;
041 updateTimer();
042 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
043 {open braces start code blocks and must be matched with a close brace
044 scheduleRelative(thisthis means the current object (the implicit parameter),1);
045 }close braces end code blocks and must match an earlier open brace
046 }close braces end code blocks and must match an earlier open brace
047 }close braces end code blocks and must match an earlier open brace
048 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
049 {open braces start code blocks and must be matched with a close brace
050 dot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("GGC.gif");
051 dot.setImage("Bearpaw.png");
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("GGC.gif");
057 redDot.setImage("Bearpaw.png");
058 redDot.setScale(0.1);
059 redDot.setLocation(
060 random.nextDouble(),
061 random.nextDouble());
062 redDot.setColor(Color.RED);
063
064 blueDot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Bearpaw.png");
065 blueDot.setImage("GGC.gif");
066 blueDot.setScale(0.2);
067 blueDot.setLocation(
068 random.nextDouble(),
069 random.nextDouble());
070 blueDot.setColor(Color.BLUE);
071
072 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);
073 scoreSprite.setHeight(0.1);
074 scoreSprite.rightJustify();
075 scoreSprite.topJustify();
076 scoreSprite.setLocation(1, 0);
077
078
079 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);
080 timerSprite.leftJustify();
081 timerSprite.topJustify();
082 timerSprite.setHeight(0.1);
083 timerSprite.setLocation(0,0);
084 }close braces end code blocks and must match an earlier open brace
085
086 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
087 {open braces start code blocks and must be matched with a close brace
088 canvas.addSprite(dot);
089 canvas.addSprite(redDot);
090 canvas.addSprite(blueDot);
091 canvas.addSprite(scoreSprite);
092 canvas.addSprite(timerSprite);
093 }close braces end code blocks and must match an earlier open brace
094
095 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateTimer()
096 {open braces start code blocks and must be matched with a close brace
097 timerSprite.setText("Timer: "+adds two numbers together or concatenates Strings togethertimeLeft);
098 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft<1)
099 sound.play();
100 }close braces end code blocks and must match an earlier open brace
101 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value repositionRandomly(Sprite sprite)
102 {open braces start code blocks and must be matched with a close brace
103 sprite.setLocation(
104 random.nextDouble(),
105 random.nextDouble());
106 }close braces end code blocks and must match an earlier open brace
107 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value updateScore()
108 {open braces start code blocks and must be matched with a close brace
109 scoreSprite.setText("Score: "+adds two numbers together or concatenates Strings togetherscore);
110 }close braces end code blocks and must match an earlier open brace
111
112 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
113 {open braces start code blocks and must be matched with a close brace
114 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.intersects(blueDot))
115 {open braces start code blocks and must be matched with a close brace
116 repositionRandomly(blueDot);
117 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.getColor().equals(Color.BLUE))
118 {open braces start code blocks and must be matched with a close brace
119
120 dot.setColor(Color.RED);
121 dot.setScale(0.1);
122 dot.setImage("Bearpaw.png");
123 score++this is the increment operator, which increases the variable by 1;
124 sound2.play();
125
126 }close braces end code blocks and must match an earlier open brace
127 elseelse is what happens when the if condition is false
128 {open braces start code blocks and must be matched with a close brace
129 score--this is the decrement operator, which decreases the variable by 1;
130 }close braces end code blocks and must match an earlier open brace
131 updateScore();
132 }close braces end code blocks and must match an earlier open brace
133 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.intersects(redDot))
134 {open braces start code blocks and must be matched with a close brace
135 repositionRandomly(redDot);
136 ifif executes the next statement only if the condition in parenthesis evaluates to true(dot.getColor().equals(Color.RED))
137 {open braces start code blocks and must be matched with a close brace
138
139 dot.setColor(Color.BLUE);
140 dot.setScale(0.2);
141 dot.setImage("GGC.gif");
142 score++this is the increment operator, which increases the variable by 1;
143 sound2.play();
144
145 }close braces end code blocks and must match an earlier open brace
146 elseelse is what happens when the if condition is false
147 {open braces start code blocks and must be matched with a close brace
148 score--this is the decrement operator, which decreases the variable by 1;
149 }close braces end code blocks and must match an earlier open brace
150 updateScore();
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 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)
154 {open braces start code blocks and must be matched with a close brace
155
156 ifif executes the next statement only if the condition in parenthesis evaluates to true(timeLeft>0)
157 {open braces start code blocks and must be matched with a close brace
158 Point2D.Double mouse=this assignment operator makes the left side equal to the right side
159 getPlayer().getMouse().getLocation();
160 dot.setLocation(mouse);
161 handleCollisions();
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 }close braces end code blocks and must match an earlier open brace
165
166
|
Download/View Abbie/wackadot/Wackadot.java