From ggc
|
01 packagepackage is used to name the directory or folder a class is in HemendraPullay;
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 /**
09 * All about my game here.
10 * @authornull Hpullay
11 */
12 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 EquallySpaced extendsextends means to customize or extend the functionality of a class GameLoop
13 {open braces start code blocks and must be matched with a close brace
14 /**an oval*/
15 privateprivate is used to restrict access to the current class only Sprite rectangle;
16 privateprivate is used to restrict access to the current class only Sprite wall;
17 privateprivate is used to restrict access to the current class only Sprite moving;
18 privateprivate is used to restrict access to the current class only ProjectileTracker paddle;
19 privateprivate is used to restrict access to the current class only ProjectileTracker ballTracker;
20
21
22 /**sets up the game*/
23 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value startGame()
24 {open braces start code blocks and must be matched with a close brace
25 makeSprites();
26 addSprites();
27 }close braces end code blocks and must match an earlier open brace
28
29 /**makes the sprites*/
30 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeSprites()
31 {open braces start code blocks and must be matched with a close brace
32 {open braces start code blocks and must be matched with a close brace
33 intint is the type for whole numbers and it is short for integer numBricksHigh=this assignment operator makes the left side equal to the right side4;
34 doubledouble is the type for numbers that can contain decimal fractions startLocationY=this assignment operator makes the left side equal to the right side0.25;
35 doubledouble is the type for numbers that can contain decimal fractions endLocationY=this assignment operator makes the left side equal to the right side1-startLocationY;
36 doubledouble is the type for numbers that can contain decimal fractions distanceHigh=this assignment operator makes the left side equal to the right sideendLocationY-startLocationY;
37 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<numBricksHigh; j++this is the increment operator, which increases the variable by 1)
38 {open braces start code blocks and must be matched with a close brace
39 doubledouble is the type for numbers that can contain decimal fractions y=this assignment operator makes the left side equal to the right sidej*distanceHigh/(numBricksHigh-1)+adds two numbers together or concatenates Strings togetherstartLocationY;
40
41 intint is the type for whole numbers and it is short for integer numBricksAcross=this assignment operator makes the left side equal to the right side10;
42 doubledouble is the type for numbers that can contain decimal fractions startLocationX=this assignment operator makes the left side equal to the right side0.1;
43 doubledouble is the type for numbers that can contain decimal fractions endLocationX=this assignment operator makes the left side equal to the right side1-startLocationX;
44 doubledouble is the type for numbers that can contain decimal fractions distanceAcross=this assignment operator makes the left side equal to the right sideendLocationX-startLocationX;
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<numBricksAcross; 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 doubledouble is the type for numbers that can contain decimal fractions x=this assignment operator makes the left side equal to the right sidei*distanceAcross/(numBricksAcross-1)+adds two numbers together or concatenates Strings togetherstartLocationX;
48 rectangle=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(2, 1);
49 rectangle.setScale(0.08);
50 rectangle.setLocation(x,y/2);
51 rectangle.setColor(Color.RED);
52 canvas.addSprite(rectangle);
53
54 }close braces end code blocks and must match an earlier open brace
55 }close braces end code blocks and must match an earlier open brace
56
57
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
61
62 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value paddle()
63 {open braces start code blocks and must be matched with a close brace
64 moving=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,1);
65 moving.setScale(.2);
66 moving.setLocation(1, 0.5);
67
68 paddle=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTracker(0.25, 0);
69 moving.setTracker(paddle);
70
71 wall=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(2,1);
72 wall.setScale(0.5);
73 wall.setLocation(.5,1);
74 }close braces end code blocks and must match an earlier open brace
75
76 /**adds the sprites to the screen*/
77 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
78 {open braces start code blocks and must be matched with a close brace
79 canvas.addSprite(rectangle);
80 canvas.addSprite(moving, wall);
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 advanceFrame(doubledouble is the type for numbers that can contain decimal fractions timePassed)
85 {open braces start code blocks and must be matched with a close brace
86 doubledouble is the type for numbers that can contain decimal fractions y=this assignment operator makes the left side equal to the right sidegetPlayer().getMouse().getLocation().y;
87 wall.setLocation(wall.getLocation().x, y);
88
89 ifif executes the next statement only if the condition in parenthesis evaluates to true(wall.intersects(moving))
90 {open braces start code blocks and must be matched with a close brace
91 doubledouble is the type for numbers that can contain decimal fractions normal=this assignment operator makes the left side equal to the right sideSprite.getNormalVector(wall.getShape(), moving.getShape());
92 tracker.bounce(normal);
93 }close braces end code blocks and must match an earlier open brace
94
95 }close braces end code blocks and must match an earlier open brace
96 }close braces end code blocks and must match an earlier open brace
|
Compiler Errors:
----------
1. ERROR in HemendraPullay/EquallySpaced.java (at line 92)
tracker.bounce(normal);
^^^^^^^
tracker cannot be resolved
----------
1 problem (1 error)
Download/View HemendraPullay/EquallySpaced.java