forked from Elkwizard/SandSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSandSim.html
124 lines (120 loc) · 2.53 KB
/
SandSim.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./Hengine/Package/Engine/Manage/HengineLoader.js"></script>
</head>
<body>
<script>
const SOUND_EFFECTS = {
fireSound: {
maxFrequency: 2000,
volume: 0.8
},
mmmm: {
maxFrequency: 5000,
volume: 0.6
},
eurm: {
maxFrequency: 10,
volume: .5
},
liquidSound: {
maxFrequency: 2000,
volume: 0.7
},
rainSound: {
maxFrequency: 10,
volume: 0.8
},
lavaSound: {
maxFrequency: 500,
volume: 1
},
solidifySound: {
maxFrequency: 10,
volume: 0.9
}
};
const EVENT_SOUND_EFFECTS = {
explosionSound: {
chance: 0.03,
maxPerFrame: 0.8,
volume: 0.3
},
thunderSound: {
chance: 1,
maxPerFrame: 2,
volume: 0.8,
variations: 3
}
};
const SYNTH_SOUND_EFFECTS = {
lightningSound: {
chance: 1,
maxPerFrame: 2,
frequency: 50,
volume: 0.3,
duration: 50,
fadeOut: 100,
wave: "sawtooth"
},
bahhumSound: {
chance: 0.005,
maxPerFrame: 5,
duration: 10,
frequency: () => Random.range(300, 500),
volume: 1,
wave: "sine",
fadeOut: 10
},
electricitySound: {
chance: 0.01,
maxPerFrame: 5,
frequency: 35,
volume: 0.05,
duration: 150,
fadeOut: 40,
wave: "square"
},
acidSound: {
chance: 0.05,
maxPerFrame: 3,
duration: 10,
frequency: () => Random.range(200, 300),
fadeOut: 1000,
wave: "sine",
volume: 1
},
coralStimulantSound: {
chance: 1,
maxPerFrame: 10,
duration: 10,
fadeOut: 20,
frequency: () => Random.range(500, 700),
volume: 0.5,
wave: "square"
}
};
function createSoundEffectResources([sound, { variations = 1 }]) {
const prefix = "sound%20effects/";
if (variations === 1)
return [new HengineSoundResource(prefix + sound + ".mp3")];
const resources = [];
for (let i = 0; i < variations; i++)
resources.push(new HengineSoundResource(prefix + sound + i + ".mp3"));
return resources;
}
function soundEffectSuffix({ variations }, inx) {
return variations === 1 ? "" : inx;
}
HengineLoader.load([
...Object.entries(EVENT_SOUND_EFFECTS).flatMap(createSoundEffectResources),
...Object.entries(SOUND_EFFECTS).flatMap(createSoundEffectResources),
new HengineScriptResource("SandSim.js")
]);
</script>
</body>
</html>