-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsoundPlayer.java
129 lines (122 loc) · 3.85 KB
/
soundPlayer.java
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class soundPlayer here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class soundPlayer extends Actor
{
boolean running = false;
boolean stop = true;
boolean mute = false;
boolean start = false;
String toPlay = "bgm";
String lastPlay = "bgm";
//lehrerthemes
private GreenfootSound bossfight = new GreenfootSound("boss_battle_#2.mp3");
private GreenfootSound bgm = new GreenfootSound("background.mp3");
private GreenfootSound watzi = new GreenfootSound("watzlawek.mp3");
private GreenfootSound westerman = new GreenfootSound("westerman.mp3");
private GreenfootSound nolde = new GreenfootSound("nolde.mp3");
private GreenfootSound nagel = new GreenfootSound("nagel.mp3");
private GreenfootSound krey = new GreenfootSound("krey.mp3");
private GreenfootSound euman = new GreenfootSound("euman.mp3");
private GreenfootSound mergard = new GreenfootSound("mergard.mp3");
private GreenfootSound quadflieg = new GreenfootSound("quadflieg.mp3");
private GreenfootSound nachtkamp = new GreenfootSound("nachtkamp.mp3");
//sfx
/**
* Act - do whatever the soundPlayer wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(toPlay != lastPlay | start == false){
if(running == false) play(toPlay);
start = true;
}
if (Greenfoot.mouseClicked(this)) {
if(mute == true){
mute = false;
setImage("images/speaker_active.png");
play(toPlay);
}
else{
mute = true;
setImage("images/speaker_inactive.png");
stopAll();
}
}
}
public void play(String sound){
toPlay = sound;
if(running == true){
stopAll();
}
if(mute != true){
if(running == false && sound == "bossfight"){
bossfight.playLoop();
running = true;
}
if(running == false && sound == "bgm"){
bgm.playLoop();
running = true;
}
if(running == false && sound == "watzi"){
watzi.playLoop();
running = true;
}
if(running == false && sound == "westerman"){
westerman.playLoop();
running = true;
}
if(running == false && sound == "nolde"){
nolde.playLoop();
running = true;
}
if(running == false && sound == "nagel"){
nagel.playLoop();
running = true;
}
if(running == false && sound == "krey"){
krey.playLoop();
running = true;
}
if(running == false && sound == "euman"){
euman.playLoop();
running = true;
}
if(running == false && sound == "mergard"){
mergard.playLoop();
running = true;
}
if(running == false && sound == "quadflieg"){
quadflieg.playLoop();
running = true;
}
if(running == false && sound == "nachtkamp"){
nachtkamp.playLoop();
running = true;
}
}
}
public void sfxPlay(String whichOne){
}
public void stopAll(){
bossfight.stop();
bgm.stop();
watzi.stop();
westerman.stop();
nolde.stop();
nagel.stop();
krey.stop();
euman.stop();
running = false;
}
protected void addedToWorld(World world)
{
setImage("images/speaker_active.png");
world = getWorld();
}
}