From ggc
|
001 packagepackage is used to name the directory or folder a class is in MattCrauswell;
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 importimport means to make the classes and/or packages available in this program Beta.OutlineTracker;
008
009 /**
010 * All about my game here.
011 * @authorthis is the Javadoc tag for documenting who created the source code Mcrauswe
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 InteractiveArt 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
016 /**Plays wonderful sound, ifif executes the next statement only if the condition in parenthesis evaluates to true game doesn't run, please remove above line forfor is a looping structure for repeatedly executing a block of code music file. It has been making it not run at some times*/
017 privateprivate is used to restrict access to the current class only Sprite title, name;
018 privateprivate is used to restrict access to the current class only Sprite dot;
019 privateprivate is used to restrict access to the current class only Sprite tri;
020 privateprivate is used to restrict access to the current class only Sprite moving;
021 /**For the shapes*/
022 privateprivate is used to restrict access to the current class only OutlineTracker tracker;
023 /**To move sprite*/
024 privateprivate is used to restrict access to the current class only Sprite square;
025 /**For another shape*/
026 privateprivate is used to restrict access to the current class only ProjectileTracker track;
027 /**For the alarm*/
028
029
030 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
031 {open braces start code blocks and must be matched with a close brace
032 makeSprites();
033 addSprites();
034 toggleAudible();
035 }close braces end code blocks and must match an earlier open brace
036
037 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
038 {open braces start code blocks and must be matched with a close brace
039 title=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Interactive Art");
040 title.setScale(.70);
041 title.setLocation(.5, .12);
042 title.setColor(Color.RED);
043
044 dot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
045 dot.setScale(.40);
046 dot.setLocation(.5, .5);
047 dot.setColor(Color.GREEN);
048
049 name=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Matt Crauswell");
050 name.setScale(.50);
051 name.setLocation(.30, .97);
052 name.setColor(Color.BLUE);
053
054 square=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(4);
055 square.setScale(0.2);
056 square.setColor(Color.WHITE);
057 square.setLocation(0.5, 0.5);
058
059 moving=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(5);
060 moving.setScale(0.2);
061 moving.setLocation(0.5, 0.5);
062 canvas.addSprite(moving);
063
064 moving=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(5);
065 moving.setScale(0.2);
066 moving.setLocation(0.5, 0.25);
067 canvas.addSprite(moving);
068
069 tri=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(3);
070 tri.setScale(0.1);
071 tri.setLocation(0.5, 0.5);
072 tri.setColor(Color.RED);
073 /**All of the above are the attributes of the shapes that are made*/
074
075 Sprite outline=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(3);
076 outline.setScale(0.5);
077 outline.setLocation(0.5, 0.5);
078 outline.setColor(Color.BLACK);
079 canvas.addSprite(outline);
080
081 tracker=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTracker(outline, 0.5);
082 tri.setTracker(tracker);
083 tri.setLocation(tracker.getCurrentPoint());
084 /**This makes the tracker forfor is a looping structure for repeatedly executing a block of code its outline*/
085
086 Point2D.Double direction=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Point2D.Double(0.0, 0.0);
087 track=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(direction);
088 /**rotate 1/2 a revolution per second*/
089 track.setAngularVelocity(5);
090 square.setTracker(track);
091 /**This sets the square to rotate and how fast ti rotates as well*/
092
093 setHelpText("Click the start button and help Mr. Triangle fit in his small teepee!");
094
095 }close braces end code blocks and must match an earlier open brace
096
097 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
098 {open braces start code blocks and must be matched with a close brace
099 canvas.addSprite(title, name);
100 canvas.addSprite(dot);
101 canvas.addSprite(tri);
102 canvas.addSprite(square);
103 }close braces end code blocks and must match an earlier open brace
104
105 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)
106 {open braces start code blocks and must be matched with a close brace
107 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
108 //did they click at all
109 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)
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(tri.intersects(click))
112 {open braces start code blocks and must be matched with a close brace
113 canvas.removeSprite(tri);
114 }close braces end code blocks and must match an earlier open brace
115 }close braces end code blocks and must match an earlier open brace
116 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getKeyboard().getLastKey()==this is the comparison operator which evaluates to true if both sides are the same'e')
117 {open braces start code blocks and must be matched with a close brace
118 dot.setColor(Color.BLUE);
119 }close braces end code blocks and must match an earlier open brace
120 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getKeyboard().getLastKey()==this is the comparison operator which evaluates to true if both sides are the same'r')
121 {open braces start code blocks and must be matched with a close brace
122 dot.setColor(Color.RED);
123 }close braces end code blocks and must match an earlier open brace
124 }close braces end code blocks and must match an earlier open brace
125
126 }close braces end code blocks and must match an earlier open brace
|
Download/View MattCrauswell/InteractiveArt.java