File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change @@ -112,6 +112,16 @@ var setupText = function () {
112112
113113setupText ( ) ;
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+
115125var 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 }
You can’t perform that action at this time.
0 commit comments