-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsound.js
266 lines (251 loc) · 8.09 KB
/
sound.js
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
Howler.volume(game.volume);
var buttonClick = new Howl({
src: ['sound/buttonClick.mp3'],
preload: true,
});
var buttonHover = new Howl({
src: ['sound/talk.wav'],
preload: true,
volume: 0.5,
});
var menuMusic = new Howl({
src: ['sound/stuntmaster.mp3'],
preload: true,
loop: true,
volume: game.musicVolume,
});
var TGMSoundEffects = new Howl({
src: ['sound/TGMSoundEffects.mp3'],
preload: true,
volume: 0.8,
sprite: {
coinEnter: [0, 1800],
ready: [1900, 1800],
go: [3780, 1200],
pieceO: [5200, 1000],
pieceJ: [6430, 1000],
pieceL: [7640, 1000],
pieceZ: [9060, 1000],
pieceS: [10330, 1000],
pieceT: [11550, 1000],
pieceI: [12950, 1000],
IRS: [14420, 800],
lock: [15300, 500],
land: [15880, 500],
}
});
var lockSound = new Howl({
src: ['sound/plastic_box_impact_bullet5.mp3'],
preload: true,
volume: 0.5,
});
var breakSound = new Howl({
src: ['sound/etc06.wav'],
preload: true,
volume: 0.5,
});
var levelUp = new Howl({
src: ['sound/levelUp.wav'],
preload: true,
volume: 0.5,
});
var endSound = new Howl({
src: ['sound/fail.wav'],
preload: true,
});
var finishSound = new Howl({
src: ['sound/Applause.ogg'],
preload: true,
volume: 0.4,
});
var gameMusic1;
var gameMusic2;
var gameMusic3;
var gameMusic4;
var gameMusic5;
var gameMusic6;
var gameMusic7;
function initializeGameMusic() {
gameMusic1 = new Howl({
src: ['sound/wireframe-aural-imbalance.mp3'],
preload: true,
loop: true,
volume: 0.4 * game.musicVolume,
});
gameMusic2 = new Howl({
src: ['sound/tensor-jlm-productions.mp3'],
preload: true,
loop: true,
volume: 0.4 * game.musicVolume,
});
gameMusic3 = new Howl({
src: ['sound/Night Stream.mp3'],
preload: true,
loop: true,
volume: 0.4 * game.musicVolume,
});
gameMusic4 = new Howl({
src: ['sound/Pearl Blue Soul.mp3'],
preload: true,
loop: true,
volume: 0.4 * game.musicVolume,
});
gameMusic5 = new Howl({
src: ['sound/Vanishing Horizon.mp3'],
preload: true,
loop: true,
volume: 0.4 * game.musicVolume,
});
gameMusic6 = new Howl({
src: ['sound/Tek Trek.mp3'],
preload: true,
loop: true,
volume: 0.4 * game.musicVolume,
});
gameMusic7 = new Howl({
src: ['sound/Death-By-Glamour.mp3'],
preload: true,
volume: game.musicVolume,
});
}
function playSound(sound, levelTransition=false) {
if (!soundEnabled) return;
switch(sound) {
case "buttonClick":
buttonClick.play();
break;
case "buttonHover":
buttonHover.play();
break;
case "menuMusic":
menuMusic.play();
break;
case "ready":
TGMSoundEffects.play("ready");
break;
case "go":
TGMSoundEffects.play("go");
break;
case "gameMusic":
if ((settings.visuals == "classicStyle" || settings.visuals == "masterStyle" || settings.visuals == "dragonStyle") && level >= 485 && level < 500 && !levelTransition) {break;} //Intermission
else if (settings.visuals == "classicStyle" && (level >= 500 || levelTransition)) {gameMusic2.play();}
else if (settings.visuals == "classicStyle") {gameMusic1.play();}
else if (settings.visuals == "masterStyle" && (level >= 500 || levelTransition)) {gameMusic4.play();}
else if (settings.visuals == "masterStyle") {gameMusic3.play();}
else if (settings.visuals == "dragonStyle" && (level >= 500 || levelTransition)) {gameMusic6.play();}
else if (settings.visuals == "dragonStyle") {gameMusic5.play();}
else if (settings.visuals == "onTheBeat") {gameMusic7.play();}
break;
case "pieceO":
TGMSoundEffects.play("pieceO");
break;
case "pieceJ":
TGMSoundEffects.play("pieceJ");
break;
case "pieceL":
TGMSoundEffects.play("pieceL");
break;
case "pieceZ":
TGMSoundEffects.play("pieceZ");
break;
case "pieceS":
TGMSoundEffects.play("pieceS");
break;
case "pieceT":
TGMSoundEffects.play("pieceT");
break;
case "pieceI":
TGMSoundEffects.play("pieceI");
break;
case "IRS":
TGMSoundEffects.play("IRS");
break;
case "land":
TGMSoundEffects.play("land");
break;
case "lock":
if (settings.visuals == "tgm") {TGMSoundEffects.play("lock");}
else {lockSound.play();}
break;
case "lineClear":
breakSound.play();
break;
case "levelUp":
levelUp.play();
break;
case "end":
endSound.play();
break;
case "finish":
finishSound.play();
break;
}
}
function stopSound(sound) {
if (!soundEnabled) return;
switch(sound) {
case "menuMusic":
menuMusic.stop();
break;
case "gameMusic":
gameMusic1.stop();
gameMusic2.stop();
gameMusic3.stop();
gameMusic4.stop();
gameMusic5.stop();
gameMusic6.stop();
gameMusic7.stop();
break;
}
}
function setSoundVolume(sound, vol) {
if (!soundEnabled) return;
switch(sound) {
case "menuMusic":
menuMusic.volume(vol);
break;
case "gameMusic":
gameMusic1.volume(vol * 0.4);
gameMusic2.volume(vol * 0.4);
gameMusic3.volume(vol * 0.4);
gameMusic4.volume(vol * 0.4);
gameMusic5.volume(vol * 0.4);
gameMusic6.volume(vol * 0.4);
gameMusic7.volume(vol);
break;
}
}
function fadeOutSound(sound, length) {
if (!soundEnabled) return;
switch(sound) {
case "menuMusic":
menuMusic.fade(game.musicVolume, 0, length);
break;
case "gameMusic":
if (settings.visuals == "classicStyle" && level >= 500) {gameMusic2.fade(0.4 * game.musicVolume, 0, length);}
else if (settings.visuals == "classicStyle") {gameMusic1.fade(0.4 * game.musicVolume, 0, length);}
else if (settings.visuals == "masterStyle" && level >= 500) {gameMusic4.fade(0.4 * game.musicVolume, 0, length);}
else if (settings.visuals == "masterStyle") {gameMusic3.fade(0.4 * game.musicVolume, 0, length);}
else if (settings.visuals == "dragonStyle" && level >= 500) {gameMusic6.fade(0.4 * game.musicVolume, 0, length);}
else if (settings.visuals == "dragonStyle") {gameMusic5.fade(0.4 * game.musicVolume, 0, length);}
else if (settings.visuals == "onTheBeat") {gameMusic7.fade(game.musicVolume, 0, length);}
break;
}
}
function fadeInSound(sound, length) {
if (!soundEnabled) return;
switch(sound) {
case "menuMusic":
menuMusic.fade(0, game.musicVolume, length);
break;
case "gameMusic":
if (settings.visuals == "classicStyle" && level >= 500) {gameMusic2.fade(0, 0.4 * game.musicVolume, length);}
else if (settings.visuals == "classicStyle") {gameMusic1.fade(0, 0.4 * game.musicVolume, length);}
else if (settings.visuals == "masterStyle" && level >= 500) {gameMusic4.fade(0, 0.4 * game.musicVolume, length);}
else if (settings.visuals == "masterStyle") {gameMusic3.fade(0, 0.4 * game.musicVolume, length);}
else if (settings.visuals == "dragonStyle" && level >= 500) {gameMusic6.fade(0, 0.4 * game.musicVolume, length);}
else if (settings.visuals == "dragonStyle") {gameMusic5.fade(0, 0.4 * game.musicVolume, length);}
else if (settings.visuals == "onTheBeat") {gameMusic7.fade(0, game.musicVolume, length);}
break;
}
}