|
001 importimport means to make the classes and/or packages available in this program fang.*;
002 importimport means to make the classes and/or packages available in this program java.awt.*;
003 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
004
005 /**
006 * All about my game here.
007 * @authornull Valerie Hagen
008 */
009 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
010 {open braces start code blocks and must be matched with a close brace
011 privateprivate is used to restrict access to the current class only Sprite box1;
012 privateprivate is used to restrict access to the current class only Sprite box2;
013 privateprivate is used to restrict access to the current class only Sprite box3;
014 privateprivate is used to restrict access to the current class only StringSprite box1Sprite;
015 privateprivate is used to restrict access to the current class only StringSprite box2Sprite;
016 privateprivate is used to restrict access to the current class only StringSprite box3Sprite;
017 privateprivate is used to restrict access to the current class only StringSprite box4Sprite;
018 privateprivate is used to restrict access to the current class only StringSprite box5Sprite;
019 privateprivate is used to restrict access to the current class only Sprite dot;
020 privateprivate is used to restrict access to the current class only ImageSprite diamond;
021 privateprivate is used to restrict access to the current class only Sprite explosion;
022 privateprivate is used to restrict access to the current class only Sprite explosion2;
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 prize;
024
025
026
027 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
028 {open braces start code blocks and must be matched with a close brace
029 makeSprites();
030 addSprites();
031 toggleAudible();
032 }close braces end code blocks and must match an earlier open brace
033
034 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
035 {open braces start code blocks and must be matched with a close brace
036
037 Sound sound=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound("Applause2.wav");
038 sound.play(0.25);
039
040 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);
041 box1.setScale(0.25);
042 box1.setLocation(.1, .5);
043
044 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);
045 box2.setScale(0.25);
046 box2.setLocation(0.5, 0.5);
047
048 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);
049 box3.setScale(0.25);
050 box3.setLocation(.9,.5);
051
052
053 box1Sprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Door 1");
054 box1Sprite.setHeight(0.05);
055 box1Sprite.setLocation(.1, .7);
056
057 box2Sprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Door 2");
058 box2Sprite.setHeight(0.05);
059 box2Sprite.setLocation(.5, .7);
060
061 box3Sprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Door 3");
062 box3Sprite.setHeight(0.05);
063 box3Sprite.setLocation(.9, .7);
064
065 box4Sprite=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!");
066 box4Sprite.setHeight(0.09);
067 box4Sprite.setLocation(.5, .1);
068
069 box5Sprite=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("By Valerie Hagen!");
070 box5Sprite.setHeight(0.05);
071 box5Sprite.setLocation(.5, .9);
072
073 Ellipse2D.Double circle=this assignment operator makes the left side equal to the right side
074 newnew is used to create objects by calling the constructor Ellipse2D.Double(0, 0, 1, 1);
075
076
077 diamond=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Diamond.gif"));
078 diamond.setScale(0.1);
079 diamond.setColor(Color.RED);
080
081
082 explosion=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Explosion.gif"));
083 explosion.setScale(0.1);
084 explosion.setColor(Color.RED);
085
086 explosion2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite(Wiki.getMedia("Explosion.gif"));
087 explosion2.setScale(0.1);
088 explosion2.setColor(Color.GREEN);
089
090
091 prize=this assignment operator makes the left side equal to the right siderandom.nextInt(3)+adds two numbers together or concatenates Strings together1;
092 ifif executes the next statement only if the condition in parenthesis evaluates to true(prize==this is the comparison operator which evaluates to true if both sides are the same1)
093
094 {open braces start code blocks and must be matched with a close brace
095 diamond.setLocation(.1, 0.5);
096 explosion.setLocation(0.5, 0.5);
097 explosion2.setLocation(0.9, 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(prize==this is the comparison operator which evaluates to true if both sides are the same2)
100 {open braces start code blocks and must be matched with a close brace
101 diamond.setLocation(0.9, 0.5);
102 explosion.setLocation(0.1, 0.5);
103 explosion2.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 (prize==this is the comparison operator which evaluates to true if both sides are the same3)
106 {open braces start code blocks and must be matched with a close brace
107 diamond.setLocation(.5, 0.5);
108 explosion.setLocation(0.9, 0.5);
109 explosion2.setLocation(0.1, 0.5);
110 }close braces end code blocks and must match an earlier open brace
111
112
113 }close braces end code blocks and must match an earlier open brace
114
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
118 canvas.addSprite(diamond);
119 canvas.addSprite(explosion);
120 canvas.addSprite(explosion2);
121 canvas.addSprite(box1);
122 canvas.addSprite(box2);
123 canvas.addSprite(box3);
124 canvas.addSprite(box1Sprite);
125 canvas.addSprite(box2Sprite);
126 canvas.addSprite(box3Sprite);
127 canvas.addSprite(box4Sprite);
128 canvas.addSprite(box5Sprite);
129
130
131
132
133
134 }close braces end code blocks and must match an earlier open brace
135
136 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)
137 {open braces start code blocks and must be matched with a close brace
138 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
139 //did they click at all
140 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)
141 {open braces start code blocks and must be matched with a close brace
142 ifif executes the next statement only if the condition in parenthesis evaluates to true(box1.intersects(click))
143 {open braces start code blocks and must be matched with a close brace
144 canvas.removeSprite(box2);
145
146
147 }close braces end code blocks and must match an earlier open brace
148 ifif executes the next statement only if the condition in parenthesis evaluates to true(box2.intersects(click))
149 {open braces start code blocks and must be matched with a close brace
150 canvas.removeSprite(box3);
151
152
153 }close braces end code blocks and must match an earlier open brace
154 ifif executes the next statement only if the condition in parenthesis evaluates to true(box3.intersects(click))
155 {open braces start code blocks and must be matched with a close brace
156 canvas.removeSprite(box1);
157
158
159
160 }close braces end code blocks and must match an earlier open brace
161 }close braces end code blocks and must match an earlier open brace
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
|