|
001 packagepackage is used to name the directory or folder a class is in Tyler;
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 * All about my game here.
010 * @authorthis is the Javadoc tag for documenting who created the source code Tyler Walsh
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 DoorGameExperiment extendsextends means to customize or extend the functionality of a class GameLoop
014
015 {open braces start code blocks and must be matched with a close brace
016 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer y;
017 privateprivate is used to restrict access to the current class only Sprite Box1;
018 privateprivate is used to restrict access to the current class only Sprite Box2;
019 privateprivate is used to restrict access to the current class only Sprite Box3;
020 privateprivate is used to restrict access to the current class only Sprite Door1;
021 privateprivate is used to restrict access to the current class only Sprite Door2;
022 privateprivate is used to restrict access to the current class only Sprite Door3;
023 privateprivate is used to restrict access to the current class only Sprite Dot1;
024 privateprivate is used to restrict access to the current class only Sprite Dot2;
025 privateprivate is used to restrict access to the current class only Sprite Dot3;
026 intint is the type for whole numbers and it is short for integer x=this assignment operator makes the left side equal to the right siderandom.nextInt(2);
027
028
029 /**sets up the game*/
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
032
033 {open braces start code blocks and must be matched with a close brace
034 makeSprites();
035 addSprites();
036 y=this assignment operator makes the left side equal to the right siderandom.nextInt(3);
037
038 {open braces start code blocks and must be matched with a close brace
039 ifif executes the next statement only if the condition in parenthesis evaluates to true(y==this is the comparison operator which evaluates to true if both sides are the same0)
040 {open braces start code blocks and must be matched with a close brace
041 Dot1.setLocation(.18,.5);
042 Dot2.setLocation(.5,.5);
043 Dot3.setLocation(.8,.5);
044 }close braces end code blocks and must match an earlier open brace
045
046 ifif executes the next statement only if the condition in parenthesis evaluates to true (y==this is the comparison operator which evaluates to true if both sides are the same1)
047 {open braces start code blocks and must be matched with a close brace
048 Dot2.setLocation(.19,.5);
049 Dot1.setLocation(.5,.5);
050 Dot3.setLocation(.8,.5);
051 }close braces end code blocks and must match an earlier open brace
052
053 ifif executes the next statement only if the condition in parenthesis evaluates to true (y==this is the comparison operator which evaluates to true if both sides are the same2)
054 {open braces start code blocks and must be matched with a close brace
055 Dot3.setLocation(.21,.5);
056 Dot2.setLocation(.5,.5);
057 Dot1.setLocation(.8,.5);
058 }close braces end code blocks and must match an earlier open brace
059
060 }close braces end code blocks and must match an earlier open brace
061
062 }close braces end code blocks and must match an earlier open brace
063
064
065 privateprivate is used to restrict access to the current class only Sprite getMessage(String message)
066 {open braces start code blocks and must be matched with a close brace
067 StringSprite lose=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Tyler Rules");
068 lose.setScale(0.25);
069 lose.setLocation(0.5, 0.25);
070 returnreturn means to provide the result of the method and/or cease execution of the method immediately lose;
071 }close braces end code blocks and must match an earlier open brace
072
073
074 {open braces start code blocks and must be matched with a close brace
075 Box1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 1);
076 Box1.setScale(0.25);
077 Box1.setLocation(0.5, 0.5);
078 Box1.setColor(Color.ORANGE);
079
080 Box2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 1);
081 Box2.setScale(.25);
082 Box2.setLocation(0.15, 0.5);
083 Box2.setColor(Color.ORANGE);
084
085 Box3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,1);
086 Box3.setScale(.25);
087 Box3.setLocation (0.85, 0.5);
088 Box3.setColor(Color.ORANGE);
089
090 Door1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("1");
091 Door1.setScale(.2);
092 Door1.setLocation(.14,.52);
093 Door1.setColor(Color.BLACK);
094
095 Door2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("2");
096 Door2.setScale(.2);
097 Door2.setLocation(0.5,0.51);
098 Door2.setColor(Color.BLACK);
099
100 Door3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("3");
101 Door3.setScale(.2);
102 Door3.setLocation(0.85,0.51);
103 Door3.setColor(Color.BLACK);
104
105 Ellipse2D.Double circle=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Ellipse2D.Double(0,0,1,1);
106 Dot1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sprite(circle);
107 Dot1.setScale(.14);
108 Dot1.setColor(Color.GREEN);
109
110 Dot2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sprite(circle);
111 Dot2.setScale(.14);
112 Dot2.setColor(Color.RED);
113
114 Dot3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sprite(circle);
115 Dot3.setScale(.14);
116 Dot3.setColor(Color.RED);
117
118
119 }close braces end code blocks and must match an earlier open brace
120
121 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
122
123 {open braces start code blocks and must be matched with a close brace
124 message=this assignment operator makes the left side equal to the right sidegetmessage("Tyler Rules");
125 canvas.addSprite(message);
126 canvas.addSprite(Dot1);
127 canvas.addSprite(Dot2);
128 canvas.addSprite(Dot3);
129 canvas.addSprite(Box1);
130 canvas.addSprite(Box2);
131 canvas.addSprite(Box3);
132 canvas.addSprite(Door1);
133 canvas.addSprite(Door2);
134 canvas.addSprite(Door3);
135
136 }close braces end code blocks and must match an earlier open brace
137 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)
138
139
140 {open braces start code blocks and must be matched with a close brace}close braces end code blocks and must match an earlier open brace
141 }close braces end code blocks and must match an earlier open brace
|