Skip to content

Commit b16f82d

Browse files
committed
Add yeahboi looping sound
1 parent 105e06f commit b16f82d

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
body { margin: 0; }
66
canvas { width: 640px; height: 360px }
77
</style>
8+
<script src="/js/howler.js/dist/howler.min.js"></script>
89
<script src="/THREEx.KeyboardState.js"></script>
910
</head>
1011
<body>

public/mp3/sound.mp3

330 KB
Binary file not shown.

public/scripts.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ var setupText = function () {
112112

113113
setupText();
114114

115+
var sound = new Howl({
116+
src: ['/mp3/sound.mp3'],
117+
autoplay: true,
118+
loop: true,
119+
volume: 0.25,
120+
onend: function() {
121+
sound.seek(5);
122+
}
123+
});
124+
115125
var animate = function () {
116126
requestAnimationFrame( animate );
117127

@@ -179,6 +189,8 @@ var animate = function () {
179189
var collisionResults = ray.intersectObjects(obstacles);
180190

181191
if ( collisionResults.length > 0 && collisionResults[0].distance < directionVector.length() ) {
192+
sound.pause();
193+
182194
throw Error('game over!');
183195
}
184196
}

0 commit comments

Comments
 (0)