-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGSoundEffects.java
More file actions
65 lines (57 loc) · 1.47 KB
/
Copy pathGSoundEffects.java
File metadata and controls
65 lines (57 loc) · 1.47 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
64
65
/**This is interface for sounds*/
import java.io.File;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
public interface GSoundEffects{
static Clip st=null;
/**
* When we collect the head, this method sound outs
*/
default void collectedEffect() {
File sound = new File("sounds/dropEffect.wav");
try {
Clip clip = AudioSystem.getClip();
clip.open(AudioSystem.getAudioInputStream(sound));
clip.start();
Thread.sleep(clip.getMicrosecondLength() / 850);
} catch (Exception e) {
e.getMessage();
}
}
/**
* When we start the game window, this method sound outs
*/
default void welcomeToGame() {
File sound = new File("sounds/tadaa.wav");
try {
Clip clip = AudioSystem.getClip();
clip.open(AudioSystem.getAudioInputStream(sound));
clip.start();
} catch (Exception e) {
e.getMessage();
}
}
/**
* When we pass to play the game, this method sound outs
*/
default void whooEffect() {
File sound = new File("sounds/whoo.wav");
try {
Clip clip = AudioSystem.getClip();
clip.open(AudioSystem.getAudioInputStream(sound));
clip.start();
} catch (Exception e) {
e.getMessage();
}
}
default void backMusic() {
File sound = new File("sounds/mainSound.wav");
try {
Clip clip = AudioSystem.getClip();
clip.open(AudioSystem.getAudioInputStream(sound));
clip.start();
} catch (Exception e) {
e.getMessage();
}
}
}