From ggc
|
001 packagepackage is used to name the directory or folder a class is in arcade;
002
003 importimport means to make the classes and/or packages available in this program java.awt.geom.Point2D;
004 importimport means to make the classes and/or packages available in this program java.util.TreeSet;
005
006 importimport means to make the classes and/or packages available in this program fang.StringSprite;
007
008 /**
009 * This classclass is a group of fields and methods used for making objects displays any number of games
010 * and lets the player choose which one to
011 * play. ArcadeGames can also be nested
012 * which means that they can be added to other
013 * ArcadeGames.
014 * @authorthis is the Javadoc tag for documenting who created the source code jam
015 *
016 */
017 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 ArcadeGame
018 extendsextends means to customize or extend the functionality of a class ArcadeLevel
019 {open braces start code blocks and must be matched with a close brace
020 /**all of the games to choose from in thisthis means the current object (the implicit parameter) arcade
021 * in alphabetical order*/
022 privateprivate is used to restrict access to the current class only TreeSet<ArcadeLevel> levels;
023 privateprivate is used to restrict access to the current class only String name;
024 /**
025 * displays the names of the games
026 */
027 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startLevel()
028 {open braces start code blocks and must be matched with a close brace
029 ifif executes the next statement only if the condition in parenthesis evaluates to true(name==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object) name=this assignment operator makes the left side equal to the right sidegetClass().getCanonicalName();
030 ifif executes the next statement only if the condition in parenthesis evaluates to true(levels==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object)
031 {open braces start code blocks and must be matched with a close brace
032 levels=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor TreeSet<ArcadeLevel>();
033 }close braces end code blocks and must match an earlier open brace
034 ifif executes the next statement only if the condition in parenthesis evaluates to true(getParent()==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object) setParent(thisthis means the current object (the implicit parameter));
035 doubledouble is the type for numbers that can contain decimal fractions i=this assignment operator makes the left side equal to the right side0;
036 forfor is a looping structure for repeatedly executing a block of code(ArcadeLevel level: levels)
037 {open braces start code blocks and must be matched with a close brace
038 StringSprite name=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite(level.toString());
039 name.setLineHeight(1.0/levels.size());
040 ifif executes the next statement only if the condition in parenthesis evaluates to true(name.getWidth()>0.9) name.setWidth(0.9);
041 //name.leftJustify();
042 //name.topJustify();
043 name.setLocation(0.5, (i+adds two numbers together or concatenates Strings together0.5)/levels.size());
044 canvas.addSprite(name);
045 i++this is the increment operator, which increases the variable by 1;
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
049 /**thisthis means the current object (the implicit parameter) method must be called before the level
050 * starts. Call thisthis means the current object (the implicit parameter) method to add a game that
051 * could be played in the arcade. To convert a
052 * game that extendsextends means to customize or extend the functionality of a class GameLevel to one that extendsextends means to customize or extend the functionality of a class
053 * ArcadeLevel, just change what it extendsextends means to customize or extend the functionality of a class and
054 * optionally override the toString method.
055 * @paramthis is the Javadoc tag for documenting the purpose of parameters levelsToAdd the level(s) to add
056 */
057 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value addArcadeLevel(ArcadeLevel ... levelsToAdd)
058 {open braces start code blocks and must be matched with a close brace
059 ifif executes the next statement only if the condition in parenthesis evaluates to true(levels==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object) levels=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor TreeSet<ArcadeLevel>();
060 forfor is a looping structure for repeatedly executing a block of code(ArcadeLevel level: levelsToAdd)
061 {open braces start code blocks and must be matched with a close brace
062 levels.add(level);
063 level.setParent(thisthis means the current object (the implicit parameter));
064 }close braces end code blocks and must match an earlier open brace
065 }close braces end code blocks and must match an earlier open brace
066
067 /**
068 * gets the location of a click to determine
069 * which game to launch. The games are vertically
070 * separated. The click location is turned into
071 * an index into the set of games by scaling
072 * the y location of the click.
073 */
074 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 elapsed)
075 {open braces start code blocks and must be matched with a close brace
076 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
077 ifif executes the next statement only if the condition in parenthesis evaluates to true(click!=this is the not equals operator which evaluates to true if both sides are differentnullnull is the value used to refer to a non-existant object)
078 {open braces start code blocks and must be matched with a close brace
079 intint is the type for whole numbers and it is short for integer position=this assignment operator makes the left side equal to the right side(intint is the type for whole numbers and it is short for integer)(click.y*levels.size());
080 System.out.println("position is "+adds two numbers together or concatenates Strings togetherposition);
081 ArcadeLevel nextLevel=this assignment operator makes the left side equal to the right side
082 levels.toArray(newnew is used to create objects by calling the constructor ArcadeLevel[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays)[brackets are typically used to declare, initialize and index (indicate which element of) arraysposition]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
083 nextLevel.setParent(thisthis means the current object (the implicit parameter));
084 finishLevel();
085 setNextLevel(nextLevel);
086 System.out.println("finished");
087 }close braces end code blocks and must match an earlier open brace
088 }close braces end code blocks and must match an earlier open brace
089
090 /**thisthis means the current object (the implicit parameter) method must be called before the level
091 * starts. Call thisthis means the current object (the implicit parameter) method to change the
092 * defaultdefault is what is executed when no cases are matched name of thisthis means the current object (the implicit parameter) arcade.
093 * @paramthis is the Javadoc tag for documenting the purpose of parameters arcadeName the name of thisthis means the current object (the implicit parameter) arcade
094 */
095 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setName(String arcadeName)
096 {open braces start code blocks and must be matched with a close brace
097 name=this assignment operator makes the left side equal to the right sidearcadeName;
098 }close braces end code blocks and must match an earlier open brace
099
100 /**
101 * returns the name of thisthis means the current object (the implicit parameter) arcade
102 */
103 publicpublic is used to indicate unrestricted access (any other class can have access) String toString()
104 {open braces start code blocks and must be matched with a close brace
105 ifif executes the next statement only if the condition in parenthesis evaluates to true(name==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object) returnreturn means to provide the result of the method and/or cease execution of the method immediately getClass().getCanonicalName();
106 returnreturn means to provide the result of the method and/or cease execution of the method immediately name;
107 }close braces end code blocks and must match an earlier open brace
108 }close braces end code blocks and must match an earlier open brace
109
|
Download/View arcade/ArcadeGame.java