SoundExampleSummer

From ggc

Jump to: navigation, search

01 import fang.*;
02 import java.awt.*;
03 import java.awt.geom.*;
04 
05 /**
06  * All about my game here.
07  @author Jam Jenkins
08  */
09 public class SoundExampleSummer extends GameLoop
10 {
11   /**an oval*/
12   private Sprite oval;
13   private Sound sound=new Sound("DingLower.wav");
14   //private Sound sound2=new Sound("OtherSound.wav");
15 
16   /**sets up the game*/
17   public void startGame()
18   {
19     makeSprites();
20     addSprites();
21   }
22 
23   /**makes the sprites*/
24   private void makeSprites()
25   {
26     oval=new OvalSprite(21);
27     oval.setScale(0.75);
28     oval.setLocation(0.50.5);
29   }
30 
31   /**adds the sprites to the screen*/
32   private void addSprites()
33   {
34     canvas.addSprite(oval);
35   }
36 
37   /**handle input and game events*/
38   public void advanceFrame(double timePassed)
39   {
40     oval.setLocation(getPlayer().getMouse().getLocation());
41     if(getPlayer().getMouse().getClickLocation()!=null)
42     {
43       oval.setScale(random.nextDouble());
44       sound.play();
45       //sound2.play();
46     }
47     if(getPlayer().getKeyboard().getLastKey()=='r')
48     {
49       oval.setColor(Color.RED);
50     }
51     if(getPlayer().getKeyboard().getLastKey()=='w')
52     {
53       oval.setColor(Color.WHITE);
54     }
55   }
56 }


Download/View SoundExampleSummer.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter