|
001
002 packagepackage is used to name the directory or folder a class is in kim;
003
004 importimport means to make the classes and/or packages available in this program wiki.Wiki;
005 importimport means to make the classes and/or packages available in this program fang.*;
006 importimport means to make the classes and/or packages available in this program java.awt.*;
007 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
008
009 /**
010 * All about my game here.
011 * @authorthis is the Javadoc tag for documenting who created the source code Kmooney
012 */
013
014 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 LightsOutProject extendsextends means to customize or extend the functionality of a class GameLoop
015 {open braces start code blocks and must be matched with a close brace
016
017 privateprivate is used to restrict access to the current class only OvalSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays circles;
018 privateprivate is used to restrict access to the current class only StringSprite youWin;
019 privateprivate is used to restrict access to the current class only LightsOutModel model;
020
021 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
022 {open braces start code blocks and must be matched with a close brace
023
024 model=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor LightsOutModel();
025 makeCircles();
026 addSprites();
027 youWin();
028 canvas.addSprite(youWin);
029 setHelpText("Try to make the circles disappear by clicking them.");
030 }close braces end code blocks and must match an earlier open brace
031 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value youWin()
032 {open braces start code blocks and must be matched with a close brace
033 youWin=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("You Win");
034 youWin.setHeight(0.1);
035 youWin.setLocation(.5, .5);
036 youWin.setVisible(falsefalse is a value for the boolean type and means not true);
037 }close braces end code blocks and must match an earlier open brace
038
039 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeCircles()
040 {open braces start code blocks and must be matched with a close brace
041 intint is the type for whole numbers and it is short for integer index=this assignment operator makes the left side equal to the right side0;
042 circles=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays5]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arrays5]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
043 intint is the type for whole numbers and it is short for integer numBlocksHigh=this assignment operator makes the left side equal to the right side5;
044 doubledouble is the type for numbers that can contain decimal fractions startLocationY=this assignment operator makes the left side equal to the right side.17;
045 doubledouble is the type for numbers that can contain decimal fractions endLocationY=this assignment operator makes the left side equal to the right side1-startLocationY;
046 doubledouble is the type for numbers that can contain decimal fractions distanceHigh=this assignment operator makes the left side equal to the right sideendLocationY+adds two numbers together or concatenates Strings togetherstartLocationY;
047 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer j=this assignment operator makes the left side equal to the right side0; j<numBlocksHigh; j++this is the increment operator, which increases the variable by 1)
048 {open braces start code blocks and must be matched with a close brace
049 doubledouble is the type for numbers that can contain decimal fractions y=this assignment operator makes the left side equal to the right sidej*distanceHigh/(numBlocksHigh+adds two numbers together or concatenates Strings together1)+adds two numbers together or concatenates Strings togetherstartLocationY;
050
051 intint is the type for whole numbers and it is short for integer numBlocksAcross=this assignment operator makes the left side equal to the right side5;
052 doubledouble is the type for numbers that can contain decimal fractions startLocationX=this assignment operator makes the left side equal to the right side0.17;
053 doubledouble is the type for numbers that can contain decimal fractions endLocationX=this assignment operator makes the left side equal to the right side1-startLocationX;
054 doubledouble is the type for numbers that can contain decimal fractions distanceAcross=this assignment operator makes the left side equal to the right sideendLocationX+adds two numbers together or concatenates Strings togetherstartLocationX;
055 forfor is a looping structure for repeatedly executing a block of code(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 side0; i<numBlocksAcross; i++this is the increment operator, which increases the variable by 1)
056 {open braces start code blocks and must be matched with a close brace
057 doubledouble is the type for numbers that can contain decimal fractions x=this assignment operator makes the left side equal to the right sidei*distanceAcross/(numBlocksAcross+adds two numbers together or concatenates Strings together1)+adds two numbers together or concatenates Strings togetherstartLocationX;
058 circles[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
059 circles[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setScale(0.15);
060 circles[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(x,y);
061 circles[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setColor(Color.BLUE);
062 //canvas.addSprite(circles[index]);
063 index++this is the increment operator, which increases the variable by 1;
064 }close braces end code blocks and must match an earlier open brace
065 }close braces end code blocks and must match an earlier open brace
066
067 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer j=this assignment operator makes the left side equal to the right side0; j<5; j++this is the increment operator, which increases the variable by 1)
068 {open braces start code blocks and must be matched with a close brace
069 forfor is a looping structure for repeatedly executing a block of code(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 side0; i<5; i++this is the increment operator, which increases the variable by 1)
070 {open braces start code blocks and must be matched with a close brace
071
072
073 circles[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setVisible(model.isOn(i, j));
074 }close braces end code blocks and must match an earlier open brace
075 }close braces end code blocks and must match an earlier open brace
076 }close braces end code blocks and must match an earlier open brace
077
078 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
079 {open braces start code blocks and must be matched with a close brace
080 forfor is a looping structure for repeatedly executing a block of code(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 side0; r<circles.length; r++this is the increment operator, which increases the variable by 1)
081 {open braces start code blocks and must be matched with a close brace
082 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer c=this assignment operator makes the left side equal to the right side0; c<circles[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.length; c++this is the increment operator, which increases the variable by 1)
083 {open braces start code blocks and must be matched with a close brace
084 canvas.addSprite(circles[brackets are typically used to declare, initialize and index (indicate which element of) arraysr]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysc]brackets are typically used to declare, initialize and index (indicate which element of) arrays);;
085 }close braces end code blocks and must match an earlier open brace
086 }close braces end code blocks and must match an earlier open brace
087
088 }close braces end code blocks and must match an earlier open brace
089 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)
090 {open braces start code blocks and must be matched with a close brace
091
092 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
093 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)
094 {open braces start code blocks and must be matched with a close brace
095 intint is the type for whole numbers and it is short for integer row=this assignment operator makes the left side equal to the right side0;
096 intint is the type for whole numbers and it is short for integer col=this assignment operator makes the left side equal to the right side0;
097 ifif executes the next statement only if the condition in parenthesis evaluates to true(click.x> 0 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) click.x <=this evaluates to true if the left side is not more than the right side .2)
098 {open braces start code blocks and must be matched with a close brace
099 col=this assignment operator makes the left side equal to the right side0;
100 }close braces end code blocks and must match an earlier open brace
101 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(click.x> .2 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) click.x <=this evaluates to true if the left side is not more than the right side .4)
102 {open braces start code blocks and must be matched with a close brace
103 col=this assignment operator makes the left side equal to the right side1;
104 }close braces end code blocks and must match an earlier open brace
105 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(click.x> .4 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) click.x <=this evaluates to true if the left side is not more than the right side .6)
106 {open braces start code blocks and must be matched with a close brace
107 col=this assignment operator makes the left side equal to the right side2;
108 }close braces end code blocks and must match an earlier open brace
109 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true (click.x> .6 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) click.x <=this evaluates to true if the left side is not more than the right side .8)
110 {open braces start code blocks and must be matched with a close brace
111 col=this assignment operator makes the left side equal to the right side3;
112 }close braces end code blocks and must match an earlier open brace
113 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true (click.x> .8 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) click.x <=this evaluates to true if the left side is not more than the right side 1)
114 {open braces start code blocks and must be matched with a close brace
115 col=this assignment operator makes the left side equal to the right side4;
116 }close braces end code blocks and must match an earlier open brace
117 ifif executes the next statement only if the condition in parenthesis evaluates to true(click.y> 0 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) click.y <=this evaluates to true if the left side is not more than the right side .2)
118 {open braces start code blocks and must be matched with a close brace
119 row=this assignment operator makes the left side equal to the right side0;
120 }close braces end code blocks and must match an earlier open brace
121 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(click.y> .2 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) click.y <=this evaluates to true if the left side is not more than the right side .4)
122 {open braces start code blocks and must be matched with a close brace
123 row=this assignment operator makes the left side equal to the right side1;
124 }close braces end code blocks and must match an earlier open brace
125 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true (click.y> .4 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) click.y <=this evaluates to true if the left side is not more than the right side .6)
126 {open braces start code blocks and must be matched with a close brace
127 row=this assignment operator makes the left side equal to the right side2;
128 }close braces end code blocks and must match an earlier open brace
129 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(click.y> .6 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) click.y <=this evaluates to true if the left side is not more than the right side .8)
130 {open braces start code blocks and must be matched with a close brace
131 row=this assignment operator makes the left side equal to the right side3;
132 }close braces end code blocks and must match an earlier open brace
133 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(click.y> .8 &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) click.y <=this evaluates to true if the left side is not more than the right side 1)
134 {open braces start code blocks and must be matched with a close brace
135 row=this assignment operator makes the left side equal to the right side4;
136 }close braces end code blocks and must match an earlier open brace
137
138 model.play(row,col);
139 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer j=this assignment operator makes the left side equal to the right side0; j<5; j++this is the increment operator, which increases the variable by 1)
140 {open braces start code blocks and must be matched with a close brace
141 forfor is a looping structure for repeatedly executing a block of code(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 side0; i<5; i++this is the increment operator, which increases the variable by 1)
142 {open braces start code blocks and must be matched with a close brace
143
144 youWin.setVisible(model.won());
145 circles[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setVisible(model.isOn(i, j));
146 }close braces end code blocks and must match an earlier open brace
147 }close braces end code blocks and must match an earlier open brace
148
149 }close braces end code blocks and must match an earlier open brace
150
151 }close braces end code blocks and must match an earlier open brace
152
153 }close braces end code blocks and must match an earlier open brace
|