|
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.
007 * @authornull My Name Here
008 * thisthis means the current object (the implicit parameter) is not our code its wilsons
009 */
010 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 matt_mitrovich_kcie_green extendsextends means to customize or extend the functionality of a class Game
011 {open braces start code blocks and must be matched with a close brace
012
013 RectangleSprite singleBox;
014 RectangleSprite[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 box =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor RectangleSprite[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;
015 intint is the type for whole numbers and it is short for integer x;
016 privateprivate is used to restrict access to the current class only OvalSprite light;
017 /**sets up the game*/
018
019 /**This calls the display() method to set up all of the squares*/
020 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
021 {open braces start code blocks and must be matched with a close brace
022 display();
023 }close braces end code blocks and must match an earlier open brace
024 /**
025 *This method sets up all the squares in an array, it has two forfor is a looping structure for repeatedly executing a block of code loops forfor is a looping structure for repeatedly executing a block of code rows and colums
026 *Also randomizes a number between 1 and 2 and ifif executes the next statement only if the condition in parenthesis evaluates to true its 1 then set the block to be blue, otherwise white
027 */
028 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value display()
029 {open braces start code blocks and must be matched with a close brace
030 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)
031 {open braces start code blocks and must be matched with a close brace
032 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 l=this assignment operator makes the left side equal to the right side0; l<5; l++this is the increment operator, which increases the variable by 1)
033 {open braces start code blocks and must be matched with a close brace
034 singleBox =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor RectangleSprite(1,1);
035 singleBox.setSize(.15);
036 ifif executes the next statement only if the condition in parenthesis evaluates to true(x==this is the comparison operator which evaluates to true if both sides are the same1)
037 singleBox.setColor(getColor("Green"));
038 elseelse is what happens when the if condition is false
039 singleBox.setColor(getColor("Orange"));
040 singleBox.setLocation((i+adds two numbers together or concatenates Strings together.5)/5,(l+adds two numbers together or concatenates Strings together.5)/5);
041 box[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) arraysl]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 sidesingleBox;
042 addSprite(singleBox);
043 }close braces end code blocks and must match an earlier open brace
044 }close braces end code blocks and must match an earlier open brace
045 }close braces end code blocks and must match an earlier open brace
046 /**
047 *This method makes it so you can click on a box and change its color and the boxes up,down,left, and right of it
048 *When wanting to change the color it calls the invertBlock() method
049 */
050 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value clickBox()
051 {open braces start code blocks and must be matched with a close brace
052 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)
053 {open braces start code blocks and must be matched with a close brace
054 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 k=this assignment operator makes the left side equal to the right side0; k<5; k++this is the increment operator, which increases the variable by 1)
055 {open braces start code blocks and must be matched with a close brace
056 ifif executes the next statement only if the condition in parenthesis evaluates to true(getClick2D() !=this is the not equals operator which evaluates to true if both sides are different nullnull is the value used to refer to a non-existant object &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 &&) getClick2D().intersects(box[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) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays))
057 {open braces start code blocks and must be matched with a close brace
058 invertBlock(box[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) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
059 ifif executes the next statement only if the condition in parenthesis evaluates to true (j-1 >=this evaluates to true if the left side is not less than the right side0)
060 invertBlock(box[brackets are typically used to declare, initialize and index (indicate which element of) arraysj-1]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) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
061 ifif executes the next statement only if the condition in parenthesis evaluates to true (j+adds two numbers together or concatenates Strings together1 <=this evaluates to true if the left side is not more than the right side 9)
062 invertBlock(box[brackets are typically used to declare, initialize and index (indicate which element of) arraysj+adds two numbers together or concatenates Strings together1]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) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
063 ifif executes the next statement only if the condition in parenthesis evaluates to true (k-1 >=this evaluates to true if the left side is not less than the right side 0)
064 invertBlock(box[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) arraysk-1]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
065 ifif executes the next statement only if the condition in parenthesis evaluates to true (k+adds two numbers together or concatenates Strings together1 <=this evaluates to true if the left side is not more than the right side 9)
066 invertBlock(box[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) arraysk+adds two numbers together or concatenates Strings together1]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
067 }close braces end code blocks and must match an earlier open brace
068 }close braces end code blocks and must match an earlier open brace
069 }close braces end code blocks and must match an earlier open brace
070 }close braces end code blocks and must match an earlier open brace
071 /**
072 *This method inverts the RectangleSprite that you tell it to
073 *@paramnull block - thisthis means the current object (the implicit parameter) is the rectangle sprite that you want to invert
074 */
075 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value invertBlock(RectangleSprite block)
076 {open braces start code blocks and must be matched with a close brace
077 ifif executes the next statement only if the condition in parenthesis evaluates to true(getColorName(block.getColor()) ==this is the comparison operator which evaluates to true if both sides are the same getColorName(getColor("Green")))
078 block.setColor(getColor("orange"));
079 elseelse is what happens when the if condition is false
080 block.setColor(getColor("green"));
081
082 }close braces end code blocks and must match an earlier open brace
083
084 /**handle input and game events
085 *Calls the clickBox() method to change the color of the blocks.
086 */
087 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
088 {open braces start code blocks and must be matched with a close brace
089 clickBox();
090 }close braces end code blocks and must match an earlier open brace
091 }close braces end code blocks and must match an earlier open brace
092 /**
093 {open braces start code blocks and must be matched with a close brace
094 circle();
095 square();
096 }close braces end code blocks and must match an earlier open brace
097 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value circle()
098 {open braces start code blocks and must be matched with a close brace
099
100 light =this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
101 light.setSize(.5);
102 light.setLocation(.50,.50);
103 light.setColor(getColor("White"));
104 addSprite(light);
105 }close braces end code blocks and must match an earlier open brace
106 from space invaders
107 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value square()
108 {open braces start code blocks and must be matched with a close brace
109 intint is the type for whole numbers and it is short for integer enemiesAcross=this assignment operator makes the left side equal to the right side5;
110 intint is the type for whole numbers and it is short for integer enemiesDown=this assignment operator makes the left side equal to the right side5;
111 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<enemiesDown; j++this is the increment operator, which increases the variable by 1)
112 {open braces start code blocks and must be matched with a close brace
113 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 side1; i<=this evaluates to true if the left side is not more than the right sideenemiesAcross; i++this is the increment operator, which increases the variable by 1)
114 {open braces start code blocks and must be matched with a close brace
115 RectangleSprite enemy=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1, 1);
116 enemy.setSize(0.9/enemiesAcross);
117 doubledouble is the type for numbers that can contain decimal fractions x=this assignment operator makes the left side equal to the right side0.5/enemiesAcross+adds two numbers together or concatenates Strings together1.0/enemiesAcross*(i-1);
118 doubledouble is the type for numbers that can contain decimal fractions y=this assignment operator makes the left side equal to the right side0.5/enemiesAcross+adds two numbers together or concatenates Strings together(j+adds two numbers together or concatenates Strings together0.0)/enemiesAcross;
119 enemy.setLocation(x, y);
120 addSprite(enemy);
121 }close braces end code blocks and must match an earlier open brace
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 */
126
127
128 /**handle input and game events*/
|