diff --git a/backend.js b/backend.js index 8b2b066..aeafaab 100644 --- a/backend.js +++ b/backend.js @@ -10,7 +10,7 @@ const PLAYERRADIUS = 10 //16 const PLAYERSPEED = TICKRATE/5 // pixel const PLAYERHEALTH = 3 const PLAYERHEALTHMAX = 6 -const GUNHEARRANGE = 500 +const GUNHEARRANGE = 700 const PLAYER_JOIN_DELAY = 3000 //to check if there exists any player left @@ -42,10 +42,10 @@ const gunInfo = { 'railgun':{travelDistance:0, damage: 3, shake:0, num: 1, fireRate: 1000, projectileSpeed:0, magSize:2, reloadTime: 1800, ammotype:'battery', size: {length:50, width:5}}, // pierce walls and entities 'CrossBow':{travelDistance:650, damage: 15, shake:0, num: 1, fireRate: 100, projectileSpeed:10, magSize: 1, reloadTime: 1300, ammotype:'bolt', size: {length:21, width:2}}, -'M1':{travelDistance:2400, damage: 6, shake:0, num: 1, fireRate: 1600, projectileSpeed:42, magSize: 5, reloadTime: 4000, ammotype:'7mm', size: {length:42, width:4}}, -'mk14':{travelDistance:1600, damage: 3, shake:1, num: 1, fireRate: 600, projectileSpeed:32, magSize:14, reloadTime: 3300, ammotype:'7mm', size: {length:32, width:3} }, -'SLR':{travelDistance:2000, damage: 3.5, shake:1, num: 1, fireRate: 350, projectileSpeed:36, magSize: 10, reloadTime: 2700, ammotype:'7mm', size: {length:38, width:3}}, -'AWM':{travelDistance:3000, damage: 12, shake:0, num: 1, fireRate: 2000, projectileSpeed:30, magSize: 7, reloadTime: 4000, ammotype:'7mm', size: {length:50, width:5}}, +'M1':{travelDistance:2000, damage: 6, shake:0, num: 1, fireRate: 1600, projectileSpeed:42, magSize: 5, reloadTime: 4000, ammotype:'7mm', size: {length:42, width:4}}, +'mk14':{travelDistance:1000, damage: 3, shake:1, num: 1, fireRate: 600, projectileSpeed:32, magSize:14, reloadTime: 3300, ammotype:'7mm', size: {length:32, width:3} }, +'SLR':{travelDistance:1200, damage: 3.5, shake:1, num: 1, fireRate: 350, projectileSpeed:36, magSize: 10, reloadTime: 2700, ammotype:'7mm', size: {length:38, width:3}}, +'AWM':{travelDistance:2400, damage: 12, shake:0, num: 1, fireRate: 2000, projectileSpeed:30, magSize: 7, reloadTime: 4000, ammotype:'7mm', size: {length:50, width:5}}, 'pistol':{travelDistance:400, damage: 1, shake:3, num: 1, fireRate: 300, projectileSpeed:20, magSize:15, reloadTime: 1100, ammotype:'5mm', size: {length:17, width:2}}, 'M249':{travelDistance:800, damage: 1, shake:1, num: 1, fireRate: 75, projectileSpeed:28, magSize:150, reloadTime: 7400, ammotype:'5mm', size: {length:28, width:6}}, @@ -495,7 +495,7 @@ io.on('connection', (socket) => { console.log('a user connected'); // give server info to a frontend - socket.emit('serverVars', {gunInfo, ammoInfo, PLAYERSPEED}) + socket.emit('serverVars', {gunInfo, ammoInfo, consumableInfo, PLAYERSPEED}) // projectile spawn socket.on('shoot',({x,y,angle, mousePos, currentGun,playerIdEXACT}) => { diff --git a/gun informations.xlsx b/gun informations.xlsx new file mode 100644 index 0000000..648b01b Binary files /dev/null and b/gun informations.xlsx differ diff --git a/public/js/classes/Player.js b/public/js/classes/Player.js index c703d7a..61107f7 100644 --- a/public/js/classes/Player.js +++ b/public/js/classes/Player.js @@ -92,7 +92,7 @@ class Player { c.lineWidth = bodywidth c.stroke() - } else if(thisguninfo.travelDistance >= 1200){ // snipters except VSS (can shoot all across the screen) + } else if(thisguninfo.projectileSpeed >= 30){ // snipters except VSS (can shoot all across the screen) const tipsize = 3 const tipstart = itemlength- tipsize const tipwidth = itemSize.width + thisguninfo.damage/3 diff --git a/public/js/eventListeners.js b/public/js/eventListeners.js index 2565dfb..5758ebd 100644 --- a/public/js/eventListeners.js +++ b/public/js/eventListeners.js @@ -39,8 +39,8 @@ function shootProj(event){ if (!listen) {return} // not ready to eat listen = false // block - let consumeSound = new Audio(`/consumeSound/${currentItemName}.mp3`) - consumeSound.play() + const consumeSound = frontEndConsumableSounds[currentItemName]// new Audio(`/consumeSound/${currentItemName}.mp3`) + consumeSound.cloneNode(true).play() // decrease amount here (if needed in future) @@ -181,8 +181,8 @@ function reloadGun(){ listen = false // block //console.log("reloading!") - let gunSound = new Audio(`/reloadSound/${currentGunName}.mp3`) - gunSound.play() + let reloadSound = frontEndGunReloadSounds[currentGunName] //new Audio(`/reloadSound/${currentGunName}.mp3`) + reloadSound.cloneNode(true).play() // reload ammo here!!!!! frontEndPlayer.reloading = true @@ -247,7 +247,7 @@ function interactItem(itemId,backEndItems){ listen = false //console.log("interacting!") - let interactSound = new Audio("/sound/interact.mp3") + interactSound.play() // interact here! diff --git a/public/js/frontend.js b/public/js/frontend.js index 1345eed..72a732f 100644 --- a/public/js/frontend.js +++ b/public/js/frontend.js @@ -5,8 +5,17 @@ const TICKRATE = 15 const gunInfoFrontEnd = {} let gunInfoKeysFrontEnd = [] +let frontEndGunSounds = {} +let frontEndGunReloadSounds = {} + const ammoInfoFrontEnd = {} let ammoInfoKeysFrontEnd = [] +const interactSound = new Audio("/sound/interact.mp3") + +let frontEndConsumableSounds = {} +let consumableInfoKeysFrontEnd = [] + + const SCREENWIDTH = 1024//1920// const SCREENHEIGHT = 576//1080// @@ -23,9 +32,9 @@ let listen = true // very important for event listener // initialize server variables -socket.on('serverVars',( {gunInfo, ammoInfo, PLAYERSPEED})=>{ +socket.on('serverVars',( {gunInfo, ammoInfo, consumableInfo, PLAYERSPEED})=>{ PLAYERSPEEDFRONTEND = PLAYERSPEED - + // ammo infos ammoInfoKeysFrontEnd = Object.keys(ammoInfo) for (let i=0;i{ } //console.log(ammoInfoFrontEnd) + // gun infos gunInfoKeysFrontEnd = Object.keys(gunInfo) //console.log(gunInfoKeysFrontEnd[0]) for (let i=0;i 100){ + gunSound.volume = Math.round( 10*(thatGunSoundDistance - (DISTANCE-100))/thatGunSoundDistance ) / 10 } + gunSound.cloneNode(true).play() } } @@ -251,7 +276,7 @@ socket.on('updateFrontEnd',({backEndPlayers, backEndEnemies, backEndProjectiles, gsap.to(frontEndProjectiles[id], { x: backEndProjectile.x + backEndProjectile.velocity.x, y: backEndProjectile.y + backEndProjectile.velocity.y, - duration: 0.015, + duration: 0.015, // tick ease: 'linear' }) } @@ -275,8 +300,8 @@ socket.on('updateFrontEnd',({backEndPlayers, backEndEnemies, backEndProjectiles, if (me){ const DISTANCE = Math.hypot(backendDrawable.start.x - me.x, backendDrawable.start.y - me.y) if (DISTANCE < GUNHEARRANGE) { - let gunSound = new Audio('/sound/railgun.mp3') - gunSound.play() + let gunSound = frontEndGunSounds['railgun']// new Audio('/sound/railgun.mp3') + gunSound.cloneNode(true).play() } }