|
001 packagepackage is used to name the directory or folder a class is in HemendraPullay;
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 Hpullay, Ppullay
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 letsmakeadeal 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 /**an oval*/
015 privateprivate is used to restrict access to the current class only Sprite title,subtitle,subtitle1,subtitle3,text,text1,text2;
016 privateprivate is used to restrict access to the current class only Sprite rectangle;
017 privateprivate is used to restrict access to the current class only Sprite rectangle1;
018 privateprivate is used to restrict access to the current class only Sprite rectangle2;
019 privateprivate is used to restrict access to the current class only ImageSprite prize;
020 privateprivate is used to restrict access to the current class only ImageSprite prize1;
021 privateprivate is used to restrict access to the current class only ImageSprite prize2;
022 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer x,y;
023 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer clickcount =this assignment operator makes the left side equal to the right side 0; /**sets clickcount to 0*/
024 privateprivate is used to restrict access to the current class only StringSprite losemsg;
025 privateprivate is used to restrict access to the current class only StringSprite winmsg;
026
027 /**sets up the game*/
028 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
029 {open braces start code blocks and must be matched with a close brace
030 makeSprites();
031 addSprites();
032 setHelpText("<h1>Lets Make a Deal.<h1>"+adds two numbers together or concatenates Strings together
033 "Start by Clicking on a Door.<br>"+adds two numbers together or concatenates Strings together
034 "Click on same Door or Change Selected Door.<br>");
035 }close braces end code blocks and must match an earlier open brace
036
037 /**makes the sprites*/
038 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
039 {open braces start code blocks and must be matched with a close brace
040 title=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Lets Make A Deal!");
041 title.setScale(0.65);
042 title.setLocation(0.5, 0.12);
043 title.setColor(Color.RED); /** title of program */
044
045 subtitle=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Start by clicking a Door...");
046 subtitle.setScale(0.48);
047 subtitle.setLocation(0.33, 0.19);
048 subtitle.setColor(Color.WHITE); /**Sets subtitle and give directions*/
049
050
051 subtitle3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Press 'F5' to Reset");
052 subtitle3.setScale(0.4);
053 subtitle3.setLocation(0.25, 0.94);
054 subtitle3.setColor(Color.WHITE);
055
056 rectangle=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 2);
057 rectangle.setScale(0.55);
058 rectangle.setLocation(0.2, 0.5);
059
060 text=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Door #1");
061 text.setScale(0.18);
062 text.setLocation(0.2, 0.83);
063 text.setColor(Color.WHITE);
064
065 rectangle1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 2);
066 rectangle1.setScale(0.55);
067 rectangle1.setLocation(0.5, 0.5);
068
069 text1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Door #2");
070 text1.setScale(0.18);
071 text1.setLocation(0.5, 0.83);
072 text1.setColor(Color.WHITE);
073
074 rectangle2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,2);
075 rectangle2.setScale(.55);
076 rectangle2.setLocation(.8,.5);
077
078 text2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Door #3");
079 text2.setScale(0.18);
080 text2.setLocation(0.8, 0.83);
081 text2.setColor(Color.WHITE);
082
083 prize=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Prize.JPG"));
084 prize.setScale(0.48);
085
086 prize1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Tryagain.JPG"));
087 prize1.setScale(0.48);
088
089 prize2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Tryagain1.JPG"));
090 prize2.setScale(0.48);
091
092 y=this assignment operator makes the left side equal to the right siderandom.nextInt(3);
093 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)
094 {open braces start code blocks and must be matched with a close brace
095 prize.setLocation(0.2, 0.5); /**1st door wins*/
096 prize1.setLocation(0.5, 0.5);
097 prize2.setLocation(0.8, 0.5);
098 }close braces end code blocks and must match an earlier open brace
099 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)
100 {open braces start code blocks and must be matched with a close brace
101 prize.setLocation(0.8, 0.5); /**3rd door wins*/
102 prize1.setLocation(0.2, 0.5);
103 prize2.setLocation(0.5, 0.5);
104 }close braces end code blocks and must match an earlier open brace
105 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)
106 {open braces start code blocks and must be matched with a close brace
107 prize.setLocation(0.5, 0.5); /**2nd door wins*/
108 prize1.setLocation(0.8, 0.5);
109 prize2.setLocation(0.2, 0.5);
110 }close braces end code blocks and must match an earlier open brace
111 }close braces end code blocks and must match an earlier open brace
112
113 /**adds the sprites to the screen*/
114 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
115 {open braces start code blocks and must be matched with a close brace
116 canvas.addSprite(prize);
117 canvas.addSprite(prize1);
118 canvas.addSprite(prize2);
119
120 canvas.addSprite(rectangle);
121 canvas.addSprite(rectangle1);
122 canvas.addSprite(rectangle2);
123
124 canvas.addSprite(title,subtitle,subtitle3,text,text1,text2);
125 }close braces end code blocks and must match an earlier open brace
126 /**handle input and game events*/
127
128
129 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)
130 {open braces start code blocks and must be matched with a close brace
131 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
132
133 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)
134 {open braces start code blocks and must be matched with a close brace
135 subtitle1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Click another door, or keep your selection");
136 subtitle1.setScale(0.7);
137 subtitle1.setLocation(0.4, 0.19);
138 subtitle1.setColor(Color.WHITE);
139 canvas.removeSprite(subtitle);
140 canvas.addSprite(subtitle1);
141
142 ifif executes the next statement only if the condition in parenthesis evaluates to true(rectangle.intersects(click))
143 {open braces start code blocks and must be matched with a close brace
144 intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right siderandom.nextInt(2);
145
146 ifif executes the next statement only if the condition in parenthesis evaluates to true(i==this is the comparison operator which evaluates to true if both sides are the same0)
147 {open braces start code blocks and must be matched with a close brace
148 canvas.removeSprite(rectangle1);
149 clickcount++this is the increment operator, which increases the variable by 1;
150 }close braces end code blocks and must match an earlier open brace
151 ifif executes the next statement only if the condition in parenthesis evaluates to true(i==this is the comparison operator which evaluates to true if both sides are the same1)
152 {open braces start code blocks and must be matched with a close brace
153 canvas.removeSprite(rectangle2);
154 clickcount++this is the increment operator, which increases the variable by 1;
155 }close braces end code blocks and must match an earlier open brace
156
157 }close braces end code blocks and must match an earlier open brace
158
159 ifif executes the next statement only if the condition in parenthesis evaluates to true(rectangle1.intersects(click))
160 {open braces start code blocks and must be matched with a close brace
161 intint is the type for whole numbers and it is short for integer t=this assignment operator makes the left side equal to the right siderandom.nextInt(2);
162 ifif executes the next statement only if the condition in parenthesis evaluates to true(t==this is the comparison operator which evaluates to true if both sides are the same0)
163 {open braces start code blocks and must be matched with a close brace
164 canvas.removeSprite(rectangle);
165 clickcount++this is the increment operator, which increases the variable by 1;
166 }close braces end code blocks and must match an earlier open brace
167 ifif executes the next statement only if the condition in parenthesis evaluates to true(t==this is the comparison operator which evaluates to true if both sides are the same1)
168 {open braces start code blocks and must be matched with a close brace
169 canvas.removeSprite(rectangle2);
170 clickcount++this is the increment operator, which increases the variable by 1;
171 }close braces end code blocks and must match an earlier open brace
172
173 }close braces end code blocks and must match an earlier open brace
174
175 ifif executes the next statement only if the condition in parenthesis evaluates to true(rectangle2.intersects(click))
176 {open braces start code blocks and must be matched with a close brace
177 intint is the type for whole numbers and it is short for integer r=this assignment operator makes the left side equal to the right siderandom.nextInt(2);
178 ifif executes the next statement only if the condition in parenthesis evaluates to true(r==this is the comparison operator which evaluates to true if both sides are the same0)
179 {open braces start code blocks and must be matched with a close brace
180 canvas.removeSprite(rectangle1);
181 clickcount++this is the increment operator, which increases the variable by 1;
182 }close braces end code blocks and must match an earlier open brace
183 ifif executes the next statement only if the condition in parenthesis evaluates to true(r==this is the comparison operator which evaluates to true if both sides are the same1)
184 {open braces start code blocks and must be matched with a close brace
185 canvas.removeSprite(rectangle);
186 clickcount++this is the increment operator, which increases the variable by 1;
187 }close braces end code blocks and must match an earlier open brace
188 }close braces end code blocks and must match an earlier open brace
189 }close braces end code blocks and must match an earlier open brace
190 ifif executes the next statement only if the condition in parenthesis evaluates to true(clickcount==this is the comparison operator which evaluates to true if both sides are the same2)
191 {open braces start code blocks and must be matched with a close brace
192 canvas.removeSprite(rectangle);
193 canvas.removeSprite(rectangle1);
194 canvas.removeSprite(rectangle2);
195 }close braces end code blocks and must match an earlier open brace
196
197
198 }close braces end code blocks and must match an earlier open brace
199 }close braces end code blocks and must match an earlier open brace
|