|
01 packagepackage is used to name the directory or folder a class is in jam;
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 * @authorthis is the Javadoc tag for documenting who created the source code 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 SpaceInvaders 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 /**sets up the game*/
14 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
15 {open braces start code blocks and must be matched with a close brace
16 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 side11;
17 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 side4;
18 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)
19 {open braces start code blocks and must be matched with a close brace
20 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)
21 {open braces start code blocks and must be matched with a close brace
22 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);
23 enemy.setSize(0.9/enemiesAcross);
24 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);
25 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;
26 enemy.setLocation(x, y);
27 addSprite(enemy);
28 }close braces end code blocks and must match an earlier open brace
29 }close braces end code blocks and must match an earlier open brace
30 /*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)
31 {open braces start code blocks and must be matched with a close brace
32 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);
33 enemy.setSize(0.9/enemiesAcross);
34 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);
35 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 together0.0/enemiesAcross;
36 enemy.setLocation(x, y);
37 addSprite(enemy);
38 }close braces end code blocks and must match an earlier open 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 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)
40 {open braces start code blocks and must be matched with a close brace
41 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);
42 enemy.setSize(0.9/enemiesAcross);
43 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);
44 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 together1.0/enemiesAcross;
45 enemy.setLocation(x, y);
46 addSprite(enemy);
47 }close braces end code blocks and must match an earlier open brace
48 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)
49 {open braces start code blocks and must be matched with a close brace
50 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);
51 enemy.setSize(0.9/enemiesAcross);
52 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);
53 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 together2.0/enemiesAcross;
54 enemy.setLocation(x, y);
55 addSprite(enemy);
56 }close braces end code blocks and must match an earlier open brace
57 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)
58 {open braces start code blocks and must be matched with a close brace
59 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);
60 enemy.setSize(0.9/enemiesAcross);
61 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);
62 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 together3.0/enemiesAcross;
63 enemy.setLocation(x, y);
64 addSprite(enemy);
65 }close braces end code blocks and must match an earlier open brace*/
66
67 /*RectangleSprite enemy1=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,1);
68 enemy1.setSize(0.09);
69 enemy1.setLocation(0.05, 0.05);
70 addSprite(enemy1);
71
72 RectangleSprite enemy2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,1);
73 enemy2.setSize(0.09);
74 enemy2.setLocation(0.15, 0.05);
75 addSprite(enemy2);
76
77 RectangleSprite enemy3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(1,1);
78 enemy3.setSize(0.09);
79 enemy3.setLocation(0.25, 0.05);
80 addSprite(enemy3);*/
81 }close braces end code blocks and must match an earlier open brace
82
83 /**handle input and game events*/
84 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
85 {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
86 }close braces end code blocks and must match an earlier open brace
|