From ggc
|
01 importimport means to make the classes and/or packages available in this program fang.*;
02 importimport means to make the classes and/or packages available in this program java.awt.*;
03 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
04
05 /**
06 * All about my game here.
07 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
08 */
09 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 SoundExampleSummer extendsextends means to customize or extend the functionality of a class GameLoop
10 {open braces start code blocks and must be matched with a close brace
11 /**an oval*/
12 privateprivate is used to restrict access to the current class only Sprite oval;
13 privateprivate is used to restrict access to the current class only Sound sound=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sound("DingLower.wav");
14 //private Sound sound2=new Sound("OtherSound.wav");
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 startGame()
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 OvalSprite(2, 1);
27 oval.setScale(0.75);
28 oval.setLocation(0.5, 0.5);
29 }close braces end code blocks and must match an earlier open brace
30
31 /**adds the sprites to the screen*/
32 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value addSprites()
33 {open braces start code blocks and must be matched with a close brace
34 canvas.addSprite(oval);
35 }close braces end code blocks and must match an earlier open brace
36
37 /**handle input and game events*/
38 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)
39 {open braces start code blocks and must be matched with a close brace
40 oval.setLocation(getPlayer().getMouse().getLocation());
41 ifif executes the next statement only if the condition in parenthesis evaluates to true(getPlayer().getMouse().getClickLocation()!=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)
42 {open braces start code blocks and must be matched with a close brace
43 oval.setScale(random.nextDouble());
44 sound.play();
45 //sound2.play();
46 }close braces end code blocks and must match an earlier open brace
47 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')
48 {open braces start code blocks and must be matched with a close brace
49 oval.setColor(Color.RED);
50 }close braces end code blocks and must match an earlier open brace
51 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'w')
52 {open braces start code blocks and must be matched with a close brace
53 oval.setColor(Color.WHITE);
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 }close braces end code blocks and must match an earlier open brace
|
Download/View SoundExampleSummer.java