Skip to content

Commit

Permalink
Add yeahboi looping sound
Browse files Browse the repository at this point in the history
  • Loading branch information
MattyRad committed Feb 15, 2020
1 parent 105e06f commit b16f82d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Binary file added public/mp3/sound.mp3
Binary file not shown.
12 changes: 12 additions & 0 deletions public/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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!');
}
}
Expand Down

0 comments on commit b16f82d

Please sign in to comment.