|
001 packagepackage is used to name the directory or folder a class is in PavitraPullay;
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 Ppullay, Hpullay
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;
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>"+adds two numbers together or concatenates Strings together
035 "Have Fun!");
036 }close braces end code blocks and must match an earlier open brace
037
038 /**makes the sprites*/
039 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
040 {open braces start code blocks and must be matched with a close brace
041 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!");
042 title.setScale(0.65);
043 title.setLocation(0.5, 0.12);
044 title.setColor(Color.RED);
045
046 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...");
047 subtitle.setScale(0.48);
048 subtitle.setLocation(0.33, 0.19);
049 subtitle.setColor(Color.WHITE);
050
051
052 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");
053 subtitle3.setScale(0.4);
054 subtitle3.setLocation(0.25, 0.94);
055 subtitle3.setColor(Color.WHITE);
056
057 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);
058 rectangle.setScale(0.55);
059 rectangle.setLocation(0.2, 0.5);
060
061 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");
062 text.setScale(0.18);
063 text.setLocation(0.2, 0.83);
064 text.setColor(Color.WHITE);
065
066 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);
067 rectangle1.setScale(0.55);
068 rectangle1.setLocation(0.5, 0.5);
069
070 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");
071 text1.setScale(0.18);
072 text1.setLocation(0.5, 0.83);
073 text1.setColor(Color.WHITE);
074
075 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);
076 rectangle2.setScale(.55);
077 rectangle2.setLocation(.8,.5);
078
079 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");
080 text2.setScale(0.18);
081 text2.setLocation(0.8, 0.83);
082 text2.setColor(Color.WHITE);
083
084 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"));
085 prize.setScale(0.48);
086
087 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"));
088 prize1.setScale(0.48);
089
090 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"));
091 prize2.setScale(0.48);
092
093 y=this assignment operator makes the left side equal to the right siderandom.nextInt(3);
094 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)
095 {open braces start code blocks and must be matched with a close brace
096 prize.setLocation(0.2, 0.5); /**1st door wins*/
097 prize1.setLocation(0.5, 0.5);
098 prize2.setLocation(0.8, 0.5);
099 }close braces end code blocks and must match an earlier open brace
100 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)
101 {open braces start code blocks and must be matched with a close brace
102 prize.setLocation(0.8, 0.5); /**3rd door wins*/
103 prize1.setLocation(0.2, 0.5);
104 prize2.setLocation(0.5, 0.5);
105 }close braces end code blocks and must match an earlier open brace
106 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)
107 {open braces start code blocks and must be matched with a close brace
108 prize.setLocation(0.5, 0.5); /**2nd door wins*/
109 prize1.setLocation(0.8, 0.5);
110 prize2.setLocation(0.2, 0.5);
111 }close braces end code blocks and must match an earlier open brace
112 }close braces end code blocks and must match an earlier open brace
113
114 /**adds the sprites to the screen*/
115 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
116 {open braces start code blocks and must be matched with a close brace
117 canvas.addSprite(prize);
118 canvas.addSprite(prize1);
119 canvas.addSprite(prize2);
120
121 canvas.addSprite(rectangle);
122 canvas.addSprite(rectangle1);
123 canvas.addSprite(rectangle2);
124
125 canvas.addSprite(title,subtitle,subtitle3,text,text1,text2);
126 }close braces end code blocks and must match an earlier open brace
127 /**handle input and game events*/
128
129
130 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)
131 {open braces start code blocks and must be matched with a close brace
132 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
133
134 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)
135 {open braces start code blocks and must be matched with a close brace
136 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");
137 subtitle1.setScale(0.7);
138 subtitle1.setLocation(0.4, 0.19);
139 subtitle1.setColor(Color.WHITE);
140 canvas.removeSprite(subtitle);
141 canvas.addSprite(subtitle1);
142
143 ifif executes the next statement only if the condition in parenthesis evaluates to true(rectangle.intersects(click))
144 {open braces start code blocks and must be matched with a close brace
145 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);
146
147 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)
148 {open braces start code blocks and must be matched with a close brace
149 canvas.removeSprite(rectangle1);
150 clickcount++this is the increment operator, which increases the variable by 1;
151 }close braces end code blocks and must match an earlier open brace
152 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)
153 {open braces start code blocks and must be matched with a close brace
154 canvas.removeSprite(rectangle2);
155 clickcount++this is the increment operator, which increases the variable by 1;
156 }close braces end code blocks and must match an earlier open brace
157
158 }close braces end code blocks and must match an earlier open brace
159
160 ifif executes the next statement only if the condition in parenthesis evaluates to true(rectangle1.intersects(click))
161 {open braces start code blocks and must be matched with a close brace
162 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);
163 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)
164 {open braces start code blocks and must be matched with a close brace
165 canvas.removeSprite(rectangle);
166 clickcount++this is the increment operator, which increases the variable by 1;
167 }close braces end code blocks and must match an earlier open brace
168 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)
169 {open braces start code blocks and must be matched with a close brace
170 canvas.removeSprite(rectangle2);
171 clickcount++this is the increment operator, which increases the variable by 1;
172 }close braces end code blocks and must match an earlier open brace
173
174 }close braces end code blocks and must match an earlier open brace
175
176 ifif executes the next statement only if the condition in parenthesis evaluates to true(rectangle2.intersects(click))
177 {open braces start code blocks and must be matched with a close brace
178 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);
179 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)
180 {open braces start code blocks and must be matched with a close brace
181 canvas.removeSprite(rectangle1);
182 clickcount++this is the increment operator, which increases the variable by 1;
183 }close braces end code blocks and must match an earlier open brace
184 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)
185 {open braces start code blocks and must be matched with a close brace
186 canvas.removeSprite(rectangle);
187 clickcount++this is the increment operator, which increases the variable by 1;
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 }close braces end code blocks and must match an earlier open brace
191 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)
192 {open braces start code blocks and must be matched with a close brace
193 canvas.removeSprite(rectangle);
194 canvas.removeSprite(rectangle1);
195 canvas.removeSprite(rectangle2);
196 }close braces end code blocks and must match an earlier open brace
197
198
199 }close braces end code blocks and must match an earlier open brace
200 }close braces end code blocks and must match an earlier open brace
|