|
01 packagepackage is used to name the directory or folder a class is in intro;
02
03 importimport means to make the classes and/or packages available in this program fang.*;
04 importimport means to make the classes and/or packages available in this program java.awt.*;
05 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
06
07 /**
08 * All about my game.
09 * @authornull My Name Here
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 MultiPlayerGame extendsextends means to customize or extend the functionality of a class Game
12 {open braces start code blocks and must be matched with a close brace
13 /**an oval*/
14 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;
15
16 /**sets up the game*/
17 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
18 {open braces start code blocks and must be matched with a close brace
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 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) arraysgetNumberOfPlayers()]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
27 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)
28 {open braces start code blocks and must be matched with a close brace
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=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(2, 1);
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.setSize(0.75);
31 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(0.5, 0.5);
32
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 addSprite(oval);
40 }close braces end code blocks and must match an earlier open brace
41
42 /**handle input and game events*/
43 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
44 {open braces start code blocks and must be matched with a close brace
45 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)
46 {open braces start code blocks and must be matched with a close brace
47 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(getMouse2D(i));
48 ifif executes the next statement only if the condition in parenthesis evaluates to true(getClick2D(i)!=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 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.setSize(randomDouble());
51 }close braces end code blocks and must match an earlier open brace
52 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed(i)==this is the comparison operator which evaluates to true if both sides are the same'q')
53 {open braces start code blocks and must be matched with a close brace
54 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(Palette.getColor("red"));
55 }close braces end code blocks and must match an earlier open brace
56 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed(i)==this is the comparison operator which evaluates to true if both sides are the same'w')
57 {open braces start code blocks and must be matched with a close brace
58 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(Palette.getColor("white"));
59 }close braces end code blocks and must match an earlier open brace
60 }close braces end code blocks and must match an earlier open brace
61 }close braces end code blocks and must match an earlier open brace
62 }close braces end code blocks and must match an earlier open brace
|