-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSounds.java
More file actions
63 lines (56 loc) · 1.44 KB
/
Sounds.java
File metadata and controls
63 lines (56 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* @(#)Sounds.java
*
* Sets up and gets the game's sound effects
*
* @author
* @version 1.00 2021/12/7
*/
import java.applet.*;
import java.io.*;
public class Sounds {
private File mystery = new File("ufo_lowpitch.wav"); //mystery ship/ufo appearing
private File shoot = new File("shoot.wav"); //player shoot
private File aDeath = new File("invaderkilled.wav"); //alien dies
private File pDeath = new File("explosion.wav"); //player dies
private AudioClip m,s,a,p; //mystery ship, shot, alien, and player sounds respectively
/********************** Constructor **********************/
public Sounds() {
try{
m = Applet.newAudioClip(mystery.toURL());
s = Applet.newAudioClip(shoot.toURL());
a = Applet.newAudioClip(aDeath.toURL());
p = Applet.newAudioClip(pDeath.toURL());
}
catch(Exception e){
e.printStackTrace();
}
}
/********************** Methods **********************/
//play for each sound
public void playM(){
m.play();
}
public void playS(){
s.play();
}
public void playA(){
a.play();
}
public void playP(){
p.play();
}
//stop for each sound
public void stopM(){
m.stop();
}
public void stopS(){
s.stop();
}
public void stopA(){
a.stop();
}
public void stopP(){
p.play();
}
}