|
001 packagepackage is used to name the directory or folder a class is in MattC;
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 nullnull is the value used to refer to a non-existant object
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 MakeADeal 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 Sound sound=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound(Wiki.getMedia("Sound1.wav"));
015
016 privateprivate is used to restrict access to the current class only Sprite title,text1,text2,text3;
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 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 ImageSprite prize3;
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 x,y;
024 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;
025
026 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
027 {open braces start code blocks and must be matched with a close brace
028 makeSprites();
029 addSprites();
030 toggleAudible();
031 }close braces end code blocks and must match an earlier open brace
032
033 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
034 {open braces start code blocks and must be matched with a close brace
035 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!");
036 title.setScale(.75);
037 title.setLocation(.5, .12);
038 title.setColor(Color.RED);
039
040 text1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Door 1");
041 text1.setScale(0.2);
042 text1.setLocation(0.15, 0.83);
043 text1.setColor(Color.WHITE);
044
045 text3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Door 2");
046 text3.setScale(0.2);
047 text3.setLocation(0.5, 0.83);
048 text3.setColor(Color.WHITE);
049
050 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");
051 text2.setScale(0.2);
052 text2.setLocation(0.85, 0.83);
053 text2.setColor(Color.WHITE);
054
055 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);
056 box1.setScale(0.25);
057 box1.setLocation(0.5, 0.5);
058
059 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);
060 box2.setScale(0.25);
061 box2.setLocation(.85, 0.5);
062
063 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);
064 box3.setScale(0.25);
065 box3.setLocation(.15, 0.5);
066
067 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("Moneyyy.jpg"));
068 prize1.setScale(0.2);
069
070 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("Snakeee.jpg"));
071 prize2.setScale(0.2);
072
073 prize3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Snakeee.jpg"));
074 prize3.setScale(0.2);
075
076 y=this assignment operator makes the left side equal to the right siderandom.nextInt(3);
077 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)
078 {open braces start code blocks and must be matched with a close brace
079 prize1.setLocation(0.5, 0.5);
080 prize2.setLocation(0.15, 0.5);
081 prize3.setLocation(0.85, 0.5);
082 }close braces end code blocks and must match an earlier open brace
083 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)
084 {open braces start code blocks and must be matched with a close brace
085 prize1.setLocation(0.5, 0.5);
086 prize2.setLocation(0.15, 0.5);
087 prize3.setLocation(0.85, 0.5);
088 }close braces end code blocks and must match an earlier open brace
089 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)
090 {open braces start code blocks and must be matched with a close brace
091 prize1.setLocation(0.5, 0.5);
092 prize2.setLocation(0.15, 0.5);
093 prize3.setLocation(0.85, 0.5);
094 }close braces end code blocks and must match an earlier open brace
095
096
097 }close braces end code blocks and must match an earlier open brace
098
099 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
100 {open braces start code blocks and must be matched with a close brace
101 canvas.addSprite(prize1);
102 canvas.addSprite(prize2);
103 canvas.addSprite(prize3);
104
105 canvas.addSprite(box1);
106 canvas.addSprite(box2);
107 canvas.addSprite(box3);
108
109 canvas.addSprite(title,text1,text2,text3);
110
111 }close braces end code blocks and must match an earlier open brace
112
113 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)
114 {open braces start code blocks and must be matched with a close brace
115 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
116
117 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)
118 {open braces start code blocks and must be matched with a close brace
119 ifif executes the next statement only if the condition in parenthesis evaluates to true(box1.intersects(click))
120 {open braces start code blocks and must be matched with a close brace
121 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);
122 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)
123 {open braces start code blocks and must be matched with a close brace
124 canvas.removeSprite(box2);
125 clickcount++this is the increment operator, which increases the variable by 1;
126 }close braces end code blocks and must match an earlier open brace
127 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)
128 {open braces start code blocks and must be matched with a close brace
129 canvas.removeSprite(box3);
130 clickcount++this is the increment operator, which increases the variable by 1;
131 }close braces end code blocks and must match an earlier open brace
132
133 }close braces end code blocks and must match an earlier open brace
134 ifif executes the next statement only if the condition in parenthesis evaluates to true(box2.intersects(click))
135 {open braces start code blocks and must be matched with a close brace
136 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);
137 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)
138 {open braces start code blocks and must be matched with a close brace
139 canvas.removeSprite(box1);
140 clickcount++this is the increment operator, which increases the variable by 1;
141 }close braces end code blocks and must match an earlier open brace
142 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)
143 {open braces start code blocks and must be matched with a close brace
144 canvas.removeSprite(box3);
145 clickcount++this is the increment operator, which increases the variable by 1;
146 }close braces end code blocks and must match an earlier open brace
147
148 }close braces end code blocks and must match an earlier open brace
149
150 ifif executes the next statement only if the condition in parenthesis evaluates to true(box3.intersects(click))
151 {open braces start code blocks and must be matched with a close brace
152 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);
153 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)
154 {open braces start code blocks and must be matched with a close brace
155 canvas.removeSprite(box2);
156 clickcount++this is the increment operator, which increases the variable by 1;
157 }close braces end code blocks and must match an earlier open brace
158 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)
159 {open braces start code blocks and must be matched with a close brace
160 canvas.removeSprite(box1);
161 clickcount++this is the increment operator, which increases the variable by 1;
162 }close braces end code blocks and must match an earlier open brace
163 }close braces end code blocks and must match an earlier open brace
164
165 }close braces end code blocks and must match an earlier open brace
166 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)
167 {open braces start code blocks and must be matched with a close brace
168 canvas.removeSprite(box1);
169 canvas.removeSprite(box2);
170 canvas.removeSprite(box3);
171 }close braces end code blocks and must match an earlier open brace
172
173
174 }close braces end code blocks and must match an earlier open brace
175 }close braces end code blocks and must match an earlier open brace
|