|
01 packagepackage is used to name the directory or folder a class is in JacobOlson;
02 importimport means to make the classes and/or packages available in this program fang.*;
03 importimport means to make the classes and/or packages available in this program java.awt.*;
04 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
05
06 /**
07 * All about my game here.
08 * @authornull Jolson
09 */
10 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 Feb21 extendsextends means to customize or extend the functionality of a class GameLoop
11 {open braces start code blocks and must be matched with a close brace
12 /**an oval*/
13 privateprivate is used to restrict access to the current class only Sprite[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 oval;
14
15 /**sets up the game*/
16 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
17 {open braces start code blocks and must be matched with a close brace
18 oval=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays100]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
19 makeSprites();
20 addSprites();
21 }close braces end code blocks and must match an earlier open brace
22
23 /**makes the sprites*/
24 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
25 {open braces start code blocks and must be matched with a close brace
26 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<oval.length; i++this is the increment operator, which increases the variable by 1)
27 {open braces start code blocks and must be matched with a close brace
28 oval[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=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PolygonSprite(random.nextInt(5)+adds two numbers together or concatenates Strings together3);
29 oval[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.setScale(random.nextDouble());
30 oval[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.setLocation(random.nextDouble(), random.nextDouble());
31 Color color=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Color(random.nextFloat(), random.nextFloat(), random.nextFloat());
32 oval[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.setColor(color);
33 }close braces end code blocks and must match an earlier open brace
34 }close braces end code blocks and must match an earlier open brace
35
36 /**adds the sprites to the screen*/
37 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
38 {open braces start code blocks and must be matched with a close brace
39 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<oval.length; i++this is the increment operator, which increases the variable by 1)
40 {open braces start code blocks and must be matched with a close brace
41 canvas.addSprite(oval);
42 }close braces end code blocks and must match an earlier open brace
43 }close braces end code blocks and must match an earlier open brace
44
45 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)
46 {open braces start code blocks and must be matched with a close brace
47 Point2D.Double click=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getClickLocation();
48 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)
49 {open braces start code blocks and must be matched with a close brace
50 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<oval.length; i++this is the increment operator, which increases the variable by 1)
51 {open braces start code blocks and must be matched with a close brace
52 ifif executes the next statement only if the condition in parenthesis evaluates to true(oval[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.intersects(click))
53 {open braces start code blocks and must be matched with a close brace
54 canvas.removeSprite(oval[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);
55 }close braces end code blocks and must match an earlier open brace
56 }close braces end code blocks and must match an earlier open brace
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
60 }close braces end code blocks and must match an earlier open brace
|