-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsound.js
More file actions
39 lines (39 loc) · 1.24 KB
/
Copy pathsound.js
File metadata and controls
39 lines (39 loc) · 1.24 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
var SOUND = function () {
const COPY_COUNT = 5;
function playNext() {
this.array[(this.next++)%COPY_COUNT].play();
}
var intro = document.getElementById('sound_intro'),
gamePlay = document.getElementById('sound_play'),
missionComplete = document.getElementById('sound_mission_complete'),
gameOver = document.getElementById('sound_game_over'),
UFO = document.getElementById('sound_UFO'),
explosions = [document.getElementById('sound_explosion')],
launches = [document.getElementById('sound_launch')];
intro.volume = 0.3;
gamePlay.volume = 0.3;
UFO.volume = 0.3;
explosions[0].volume = 0.2;
for(let i = 1; i < COPY_COUNT; i++) {
explosions[i] = explosions[0].cloneNode(true);
explosions[i].volume = explosions[0].volume;
launches[i] = launches[0].cloneNode(true);
}
return {
intro: intro,
gamePlay: gamePlay,
missionComplete: missionComplete,
gameOver: gameOver,
UFO: UFO,
explosion: {
array: explosions,
next: 0,
play: playNext
},
launch: {
array: launches,
next: 0,
play: playNext
}
}
}();