SampleSound

From ggc

Jump to: navigation, search

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


Download/View SampleSound.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