|
01 packagepackage is used to name the directory or folder a class is in JacobOlson;
02
03 importimport means to make the classes and/or packages available in this program wiki.Wiki;
04 importimport means to make the classes and/or packages available in this program fang.*;
05 importimport means to make the classes and/or packages available in this program java.awt.*;
06 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
07 /**
08 * The origin of my game comes from my lights out model
09 * @authornull Jolson
10 */
11 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 LightsOut extendsextends means to customize or extend the functionality of a class GameLoop
12
13 {open braces start code blocks and must be matched with a close brace
14 //these are the lights of the game
15 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=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;
16 //this helps in making the grid 5X5
17 privateprivate is used to restrict access to the current class only 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 boxs=this assignment operator makes the left side equal to the right sidenewnew 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;
18
19 //this is what places the sprites then activates the method that randomizes the lights
20 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
21 {open braces start code blocks and must be matched with a close brace
22 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<5; r++this is the increment operator, which increases the variable by 1)
23 {open braces start code blocks and must be matched with a close brace
24 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<5; c++this is the increment operator, which increases the variable by 1)
25 {open braces start code blocks and must be matched with a close brace
26 boxs[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=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,1);
27 boxs[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.setScale(.18);
28 boxs[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.setColor(Color.RED);
29 boxs[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.setLocation((0.2 * (c +adds two numbers together or concatenates Strings together 1)) - 0.1, (0.2 * (r +adds two numbers together or concatenates Strings together 1)) - 0.1);
30
31 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=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
32 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.setScale(.18);
33 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.setColor(Color.GREEN);
34 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.setLocation((0.2 * (c +adds two numbers together or concatenates Strings together 1)) - 0.1, (0.2 * (r +adds two numbers together or concatenates Strings together 1)) - 0.1);
35
36 canvas.addSprite(boxs[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, 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);
37 }close braces end code blocks and must match an earlier open brace
38 }close braces end code blocks and must match an earlier open brace
39 mixUp();
40 //when someone clicks on the help button a window with this will appear
41 setHelpText
42 ("To win, make all the lights disappear."+adds two numbers together or concatenates Strings together
43 "to reset press r");
44 }close braces end code blocks and must match an earlier open brace
45
46 //method that randomizes the lights on and off
47 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value mixUp()
48 {open braces start code blocks and must be matched with a close brace
49 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<5; r++this is the increment operator, which increases the variable by 1)
50 {open braces start code blocks and must be matched with a close brace
51 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<5; c++this is the increment operator, which increases the variable by 1)
52 {open braces start code blocks and must be matched with a close brace
53 ifif executes the next statement only if the condition in parenthesis evaluates to true(rand(10) < 6)
54 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.setVisible(falsefalse is a value for the boolean type and means not true);
55 elseelse is what happens when the if condition is false
56 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.setVisible(truetrue is the boolean value that is the opposite of false);
57 }close braces end code blocks and must match an earlier open brace
58 }close braces end code blocks and must match an earlier open brace
59 }close braces end code blocks and must match an earlier open brace
60
61 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer rand(intint is the type for whole numbers and it is short for integer high)
62 {open braces start code blocks and must be matched with a close brace
63 returnreturn means to provide the result of the method and/or cease execution of the method immediately (intint is the type for whole numbers and it is short for integer)Math.round(Math.random() * high);
64 }close braces end code blocks and must match an earlier open brace
65
66 //controls all the action that happins in this game
67 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)
68 {open braces start code blocks and must be matched with a close brace
69 Point2D.Double click =this assignment operator makes the left side equal to the right side getPlayer().getMouse().getClickLocation();
70 //i used my lights out model to help set this up
71 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 side 0; r < 5; r++this is the increment operator, which increases the variable by 1)
72 {open braces start code blocks and must be matched with a close brace
73 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 side 0; c < 5; c++this is the increment operator, which increases the variable by 1)
74 {open braces start code blocks and must be matched with a close brace
75 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 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 &&) boxs[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.intersects(click))
76 {open braces start code blocks and must be matched with a close brace
77 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.setVisible(!this is the not operator, which changes true to false and false to truecircles[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.isVisible());
78 circles[brackets are typically used to declare, initialize and index (indicate which element of) arraysMath.min(r +adds two numbers together or concatenates Strings together 1, 4)]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.setVisible(!this is the not operator, which changes true to false and false to truecircles[brackets are typically used to declare, initialize and index (indicate which element of) arraysMath.min(r +adds two numbers together or concatenates Strings together 1, 4)]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.isVisible());
79 circles[brackets are typically used to declare, initialize and index (indicate which element of) arraysMath.max(r - 1, 0)]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.setVisible(!this is the not operator, which changes true to false and false to truecircles[brackets are typically used to declare, initialize and index (indicate which element of) arraysMath.max(r - 1, 0)]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.isVisible());
80 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) arraysMath.min(c +adds two numbers together or concatenates Strings together 1, 4)]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setVisible(!this is the not operator, which changes true to false and false to truecircles[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) arraysMath.min(c +adds two numbers together or concatenates Strings together 1, 4)]brackets are typically used to declare, initialize and index (indicate which element of) arrays.isVisible());
81 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) arraysMath.max(c - 1, 0)]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setVisible(!this is the not operator, which changes true to false and false to truecircles[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) arraysMath.max(c - 1, 0)]brackets are typically used to declare, initialize and index (indicate which element of) arrays.isVisible());
82
83 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 same 0 ||this is boolean or, meaning if either or both are true then the result is true r ==this is the comparison operator which evaluates to true if both sides are the same 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 &&) (c ==this is the comparison operator which evaluates to true if both sides are the same 0 ||this is boolean or, meaning if either or both are true then the result is true c ==this is the comparison operator which evaluates to true if both sides are the same 4))
84 {open braces start code blocks and must be matched with a close brace}close braces end code blocks and must match an earlier open brace
85 elseelse is what happens when the if condition is false 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 same 0 ||this is boolean or, meaning if either or both are true then the result is true r ==this is the comparison operator which evaluates to true if both sides are the same 4 ||this is boolean or, meaning if either or both are true then the result is true c ==this is the comparison operator which evaluates to true if both sides are the same 0 ||this is boolean or, meaning if either or both are true then the result is true c ==this is the comparison operator which evaluates to true if both sides are the same 4)
86 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.setVisible(!this is the not operator, which changes true to false and false to truecircles[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.isVisible());
87 }close braces end code blocks and must match an earlier open brace
88 }close braces end code blocks and must match an earlier open brace
89 }close braces end code blocks and must match an earlier open brace
90
91 //resets the game
92 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getKeyboard().getLastKey() ==this is the comparison operator which evaluates to true if both sides are the same 'r')
93 mixUp();
94 }close braces end code blocks and must match an earlier open brace
95 }close braces end code blocks and must match an earlier open brace
|