In this game, we create a map as matrix 4x4. Then, each time users click or mouse over monster, we change its location. If user click on head of monster, he ore she get one point. In this game, we learn how to make sound every click of user.
First of all, check over the game as below:
To play sound we use this function:
You can download source code here: http://dl.tmtn.vn/1dfunction play(sound) {if (window.HTMLAudioElement) {var snd = new Audio('');if(snd.canPlayType('audio/ogg')) {snd = new Audio('sounds/' + sound + '.ogg');}else if(snd.canPlayType('audio/mp3')) {snd = new Audio('sounds/' + sound + '.mp3');}snd.play();}else {alert('HTML5 Audio is not supported by your browser!');}}
No comments:
Post a Comment