|
001 packagepackage is used to name the directory or folder a class is in NickandChris;
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 Nmckee
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 privateprivate is used to restrict access to the current class only Sprite door1;
015 privateprivate is used to restrict access to the current class only Sprite text1;
016 privateprivate is used to restrict access to the current class only Sprite door2;
017 privateprivate is used to restrict access to the current class only Sprite text2;
018 privateprivate is used to restrict access to the current class only Sprite door3;
019 privateprivate is used to restrict access to the current class only Sprite text3;
020 privateprivate is used to restrict access to the current class only Sprite GreenDot;
021 privateprivate is used to restrict access to the current class only Sprite Red1;
022 privateprivate is used to restrict access to the current class only Sprite Red2;
023 privateprivate is used to restrict access to the current class only Sprite Red3;
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 intdoor1;
025 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer intdoor2;
026 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer intdoor3;
027
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 intdoor1=this assignment operator makes the left side equal to the right siderandom.nextInt(2);
033 intdoor2=this assignment operator makes the left side equal to the right siderandom.nextInt(2);
034 intdoor3=this assignment operator makes the left side equal to the right siderandom.nextInt(2);
035 }close braces end code blocks and must match an earlier open brace
036
037
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 door3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(0,0, 1,0, 1,1, 0,1);
041 door3.setScale(0.2);
042 door3.setLocation(0.75, 0.5);
043 door3.setColor(Color.BLUE);
044 text3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("3");
045 text3.setScale(0.09);
046 text3.setLocation(0.75, 0.5);
047 text3.setColor(Color.WHITE);
048
049 Red1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
050 Red1.setScale(0.1);
051 Red1.setLocation(0.75, 0.5);
052 Red1.setColor(Color.RED);
053
054 door2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(0,0, 1,0, 1,1, 0,1);
055 door2.setScale(0.2);
056 door2.setLocation(0.5, 0.5);
057 door2.setColor(Color.BLUE);
058 text2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("2");
059 text2.setScale(0.09);
060 text2.setLocation(0.5, 0.5);
061 text2.setColor(Color.WHITE);
062
063 Red2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
064 Red2.setScale(0.1);
065 Red2.setLocation(0.5, 0.5);
066 Red2.setColor(Color.RED);
067
068 Red3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
069 Red3.setScale(0.1);
070 Red3.setLocation(0.5, 0.5);
071 Red3.setColor(Color.RED);
072
073 door1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(0,0, 1,0, 1,1, 0,1);
074 door1.setScale(0.2);
075 door1.setLocation(0.25, 0.5);
076 door1.setColor(Color.BLUE);
077 text1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("1");
078 text1.setScale(0.09);
079 text1.setLocation(0.25, 0.5);
080 text1.setColor(Color.WHITE);
081
082 GreenDot=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1, 1);
083 GreenDot.setScale(0.1);
084 GreenDot.setLocation(0.25, 0.5);
085 GreenDot.setColor(Color.GREEN);
086
087 }close braces end code blocks and must match an earlier open brace
088
089 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
090 {open braces start code blocks and must be matched with a close brace
091 canvas.addSprite(door1);
092 canvas.addSprite(door2);
093 canvas.addSprite(door3);
094 canvas.addSprite(text1);
095 canvas.addSprite(text2);
096 canvas.addSprite(text3);
097
098 }close braces end code blocks and must match an earlier open brace
099
100 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)
101 {open braces start code blocks and must be matched with a close brace
102
103 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
104 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)
105 {open braces start code blocks and must be matched with a close brace
106 ifif executes the next statement only if the condition in parenthesis evaluates to true(door3.intersects(click))
107 {open braces start code blocks and must be matched with a close brace
108
109 ifif executes the next statement only if the condition in parenthesis evaluates to true(intdoor3==this is the comparison operator which evaluates to true if both sides are the same0)
110 {open braces start code blocks and must be matched with a close brace
111 canvas.removeSprite(door3);
112 canvas.removeSprite(text3);
113 canvas.addSprite(GreenDot);
114 GreenDot.setLocation(0.75, 0.5);
115 }close braces end code blocks and must match an earlier open brace
116 elseelse is what happens when the if condition is false
117 {open braces start code blocks and must be matched with a close brace
118 canvas.addSprite(Red1);
119 Red1.setLocation(0.75, 0.5);
120 canvas.removeSprite(door3);
121 canvas.removeSprite(text3);
122 }close braces end code blocks and must match an earlier open brace
123 }close braces end code blocks and must match an earlier open brace
124
125 ifif executes the next statement only if the condition in parenthesis evaluates to true(door2.intersects(click))
126 {open braces start code blocks and must be matched with a close brace
127 ifif executes the next statement only if the condition in parenthesis evaluates to true(intdoor2==this is the comparison operator which evaluates to true if both sides are the same0)
128 {open braces start code blocks and must be matched with a close brace
129 canvas.removeSprite(door2);
130 canvas.removeSprite(text2);
131 canvas.addSprite(GreenDot);
132 GreenDot.setLocation(0.5, 0.5);
133 }close braces end code blocks and must match an earlier open brace
134 elseelse is what happens when the if condition is false
135 {open braces start code blocks and must be matched with a close brace
136 canvas.addSprite(Red2);
137 Red2.setLocation(0.5, 0.5);
138 canvas.removeSprite(door2);
139 canvas.removeSprite(text2);
140
141 }close braces end code blocks and must match an earlier open brace
142 }close braces end code blocks and must match an earlier open brace
143
144 ifif executes the next statement only if the condition in parenthesis evaluates to true(door1.intersects(click))
145 {open braces start code blocks and must be matched with a close brace
146 ifif executes the next statement only if the condition in parenthesis evaluates to true(intdoor1==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(door1);
149 canvas.removeSprite(text1);
150 canvas.addSprite(GreenDot);
151 }close braces end code blocks and must match an earlier open brace
152 elseelse is what happens when the if condition is false
153 {open braces start code blocks and must be matched with a close brace
154 canvas.addSprite(Red3);
155 Red3.setLocation(0.25, 0.5);
156 canvas.removeSprite(door1);
157 canvas.removeSprite(text1);
158
159 }close braces end code blocks and must match an earlier open brace
160
161
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 }close braces end code blocks and must match an earlier open brace
165 }close braces end code blocks and must match an earlier open brace
|