commit
This commit is contained in:
parent
beef2d1519
commit
8be4120b36
5 changed files with 23 additions and 0 deletions
BIN
assets/sounds/9mm-pistol-shot-6349.mp3
Normal file
BIN
assets/sounds/9mm-pistol-shot-6349.mp3
Normal file
Binary file not shown.
BIN
assets/sounds/shoot.mp3
Normal file
BIN
assets/sounds/shoot.mp3
Normal file
Binary file not shown.
|
@ -2,6 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="./js/class.js"></script>
|
||||
<script type="text/javascript" src="./js/sound.js"></script>
|
||||
<script type="text/javascript" src="./js/objects.js"></script>
|
||||
<script type="text/javascript" src="./js/render.js"></script>
|
||||
<script type="text/javascript" src="./js/input.js"></script>
|
||||
|
|
|
@ -22,6 +22,9 @@ let player = null;
|
|||
|
||||
Inp = new Input("canvas", Net,Renderer);
|
||||
|
||||
let sound = new Sound("./assets/sounds/");
|
||||
sound.loadSounds()
|
||||
|
||||
playerId=Net.playerId;
|
||||
player=Net.clientPlayer;
|
||||
players=Net.getPlayersToAdd();
|
||||
|
@ -90,7 +93,9 @@ function addBullets()
|
|||
bulletsToAdd.forEach((b) => {
|
||||
bullets.push(b);
|
||||
Renderer.addBullet(b);
|
||||
sound.shoot()
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function updateBullets(dt)
|
||||
|
|
17
js/sound.js
Normal file
17
js/sound.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
class Sound{
|
||||
constructor(url){
|
||||
this.assetsUrl = url;
|
||||
}
|
||||
|
||||
loadSounds(){
|
||||
console.log(this.assetsUrl + "shoot.mp3")
|
||||
this.shootSound = new Audio(this.assetsUrl + "shoot.mp3");
|
||||
this.shootSound.type = "audio/mp3";
|
||||
}
|
||||
|
||||
shoot(){
|
||||
this.shootSound.pause()
|
||||
this.shootSound.currentTime=0;
|
||||
this.shootSound.play()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue