aboutsummaryrefslogtreecommitdiff
path: root/sfx/sfx.js
blob: 71e3fe3adc6bd534fccecd3af5791222b8a1c175 (plain)
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
const Sound = {
    pass: () => {
        new Audio(kresources.sfx['pass']).play()
    },
    last: () => {
        new Audio(kresources.sfx['last']).play()
    },
    crash: () => {
        new Audio(kresources.sfx['crash']).play()
    },
    win: () => {
        new Audio(kresources.sfx['win']).play()
    },
    click: () => {
        new Audio(kresources.sfx['click']).play()
    },
    menu: () => {
        new Audio(kresources.sfx['menu']).play()
    },
    pause: () => {
        new Audio(kresources.sfx['pause']).play()
    },
    start: () => {
        new Audio(kresources.sfx['start']).play()
    },
    intro: () => {
        new Audio(kresources.music['start'].file).play()
    },
}

shouldMusicPlay = true;

setInterval(() => {
    try {
        if (typeof document.getElementById('music') !== "undefined" && typeof document.getElementById('music') !== "null") {
            if (shouldMusicPlay) {
                document.getElementById('music').play();
            }
            if (!shouldMusicPlay) {
                document.getElementById('music').pause();
            }
        }
        if (typeof b !== "undefined" && typeof b !== "null") {
            if (shouldMusicPlay) {
                b.play();
            }
            if (!shouldMusicPlay) {
                b.pause();
            }
        }
        if (typeof me !== "undefined" && typeof me !== "null") {
            if (me.currentTime < me.duration) {
                me.play();
            }
            if (me.currentTime >= me.duration) {
                me.pause();
            }
        }
    } catch (e) {}
}, 200)