-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
142 lines (133 loc) · 4.44 KB
/
index.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<html>
<head>
<title>rustle your leaves to me softly: an asmr plant dating simulator</title>
<link href="https://fonts.googleapis.com/css?family=Dancing+Script|Ubuntu" rel="stylesheet">
<style>
body { color: #519331; }
#container { width: 100%; height: 100%; display: flex; align-items: center; }
#text { margin: auto; }
#gametitle { font: 72pt 'Dancing Script', cursive; text-align: center; }
#subtitle { font: 32pt 'Ubuntu', sans-serif; text-align: center; line-height: 2.0em; color: #184A00; }
#authors { font: 16pt 'Ubuntu', sans-serif; text-align: center; color: #184A00; }
</style>
</head>
<body bgcolor="#000000">
<div id="container">
<div id="text">
<div id="gametitle">rustle your leaves to me softly</div>
<div id="subtitle">an asmr plant dating simulator</div>
<div id="authors">by @jekagames and @squinkifer</div>
</div>
</div>
<script src="/socket.io/socket.io.js"></script>
<script src="soundjs-0.6.2.min.js"></script>
<script>
createjs.Sound.on("fileload", loadHandler);
createjs.Sound.registerSound("waterdropletsloop1.ogg", "droplets");
createjs.Sound.registerSound("leavesloop1.ogg", "leaves");
createjs.Sound.registerSound("lightrainloop1.ogg", "lightrain");
createjs.Sound.registerSound("rain-dropletcomboloop1.ogg", "raindropletcombo");
createjs.Sound.registerSound("dreamscapeambienttrack.ogg", "ambient1");
createjs.Sound.registerSound("lowkeyambienttrack.ogg", "ambient2");
var i = 0;
for (i = 1; i <= 45; i++)
{
if (i < 10)
{
createjs.Sound.registerSound("poemj0"+i+".ogg", "poemj0"+i);
createjs.Sound.registerSound("poems0"+i+".ogg", "poems0"+i);
}
else
{
createjs.Sound.registerSound("poemj"+i+".ogg", "poemj"+i);
createjs.Sound.registerSound("poems"+i+".ogg", "poems"+i);
}
}
for (i = 1; i <= 10; i++)
{
if (i < 10)
{
createjs.Sound.registerSound("sciencej0"+i+".ogg", "sciencej0"+i);
createjs.Sound.registerSound("sciences0"+i+".ogg", "sciences0"+i);
}
else
{
createjs.Sound.registerSound("sciencej"+i+".ogg", "sciencej"+i);
createjs.Sound.registerSound("sciences"+i+".ogg", "sciences"+i);
}
}
function loadHandler()
{
createjs.Sound.play("lightrain", {loop:-1});
}
var music = [ "ambient1", "ambient2" ];
var sounds = [
{ "intensity": 0, "effect": "raindropletcombo", "instance": null },
{ "intensity": 100, "effect": null, "instance": null },
{ "intensity": 500, "effect": "leaves", "instance": null },
{ "intensity": 700, "effect": "droplets", "instance": null }
];
sounds[1].effect = music[getRandomInt(0, music.length)];
var voice = [
{ "intensity": 100, "lines": [], "instance": null },
{ "intensity": 300, "lines": [], "instance": null }
];
var ps = getRandomInt(0, 2) ? "j" : "s";
var ss = getRandomInt(0, 2) ? "j" : "s";
for (i = 1; i <= 45; i++)
{
if (i < 10) voice[1].lines.push("poem"+ps+"0"+i);
else voice[1].lines.push("poem"+ps+i);
}
for (i = 1; i <= 10; i++)
{
if (i < 10) voice[0].lines.push("science"+ss+"0"+i);
else voice[0].lines.push("science"+ss+i);
}
var socket = io();
socket.on('update', function(intensity)
{
for (i = 0; i < sounds.length; i++)
{
if (intensity > sounds[i].intensity)
{
if (!sounds[i].instance)
{
sounds[i].instance = createjs.Sound.play(sounds[i].effect, {loop:-1});
}
else if (sounds[i].instance.paused)
{
sounds[i].instance.paused = false;
}
var volume = intensity - sounds[i].intensity;
var VOLUME_THRESHOLD = 200;
if (volume > VOLUME_THRESHOLD) volume = VOLUME_THRESHOLD;
sounds[i].instance.volume = volume/VOLUME_THRESHOLD;
}
else if (intensity <= sounds[i].intensity && sounds[i].instance)
{
if (sounds[i].instance.volume <= 0) sounds[i].instance.paused = true;
else sounds[i].instance.volume -= 0.1;
}
}
for (i = 0; i < voice.length; i++)
{
if (intensity > voice[i].intensity)
{
if (!voice[i].instance || voice[i].instance.position == 0)
{
voice[i].instance = createjs.Sound.play(voice[i].lines[getRandomInt(0, voice[i].lines.length)]);
}
}
}
console.log(intensity);
});
function getRandomInt(min, max)
{
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
</script>
</body>
</html>