Skip to content
Permalink
Browse files

Add yeahboi looping sound

  • Loading branch information
MattyRad committed Feb 15, 2020
1 parent 105e06f commit b16f82d17742017c5dfed80a0b5fc4f2fe89e084
Showing with 13 additions and 0 deletions.
  1. +1 −0 public/index.html
  2. BIN public/mp3/sound.mp3
  3. +12 −0 public/scripts.js
@@ -5,6 +5,7 @@
body { margin: 0; }
canvas { width: 640px; height: 360px }
</style>
<script src="/js/howler.js/dist/howler.min.js"></script>
<script src="/THREEx.KeyboardState.js"></script>
</head>
<body>
BIN +330 KB public/mp3/sound.mp3
Binary file not shown.
@@ -112,6 +112,16 @@ var setupText = function () {

setupText();

var sound = new Howl({
src: ['/mp3/sound.mp3'],
autoplay: true,
loop: true,
volume: 0.25,
onend: function() {
sound.seek(5);
}
});

var animate = function () {
requestAnimationFrame( animate );

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

if ( collisionResults.length > 0 && collisionResults[0].distance < directionVector.length() ) {
sound.pause();

throw Error('game over!');
}
}

0 comments on commit b16f82d

Please sign in to comment.
You can’t perform that action at this time.