diff --git a/README.md b/README.md index e0ff105..90db58c 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,11 @@ Dans le repertoire public_html/js on retrouve le code du jeu. | ping | | Répond "pong" au websocket emetteur | | update | Information de son joueur(position, direction...) | Broadcast aux autres joueurs | | newBullet | Info d'une nouvelle balle (position, direction...)| Broadcast aux autres joueurs | -| died | Identifiant du Killeur et du killé | Broadcast aux autres joueurs | +| died | Identifiant du Killeur et du killé | Broadcast aux autres joueurs + update du joueur tué | | message | Message envoyé via concorde | Broadcast aux autres joueurs | * le ping est une commande de débug. -* update est émis à chaque modification de direction ou a chaque tp. Le serveur emet de lui même un update dès qu'un joueur meurt afin de faire respawn le joueur(en vrai il se fait juste TP au moment ou il meurt). +* update est émis à chaque modification de direction, à chaque tp ou prise de dégats. Le serveur emet de lui même un update dès qu'un joueur meurt afin de faire respawn le joueur(en vrai il se fait juste TP au moment ou il meurt). * newBullet est émis a chaque fois que quelqu'un tire. * died est émis par un joueur lorsqu'il meurt (côté client chacun check s'il a des collisions avec les balles et dès qu'il n'a plus de vie emet un "died"). * message est fait pour broadcast des messages dans le chat in game (via l'application "Concord" accessible via le téléphone (press "P")) diff --git a/public_html/about.html b/public_html/about.html index f8412e2..6eb8077 100644 --- a/public_html/about.html +++ b/public_html/about.html @@ -24,7 +24,7 @@

Ce site a été fait par RODRIGUEZ Leandro, LASSERRE Victor, Marty Killian , et REBILLARD Baptiste.

-

Ce jeu a été fait dans le cadre de la formation de L'INSA Toulouse option IR.

+

Ce jeu a été créé dans le cadre de la formation de L'INSA Toulouse option IR.

diff --git a/public_html/assets/sounds/die.mp3 b/public_html/assets/sounds/die.mp3 new file mode 100644 index 0000000..32c0ca3 Binary files /dev/null and b/public_html/assets/sounds/die.mp3 differ diff --git a/public_html/assets/sounds/shoot.mp3 b/public_html/assets/sounds/shoot.mp3 index d869ef3..3fbe77b 100644 Binary files a/public_html/assets/sounds/shoot.mp3 and b/public_html/assets/sounds/shoot.mp3 differ diff --git a/public_html/js/class.js b/public_html/js/class.js index 4e04599..c73eb54 100644 --- a/public_html/js/class.js +++ b/public_html/js/class.js @@ -47,6 +47,8 @@ class Player } }); + dieSound.play(); + net.died(this.id,killerId); } } diff --git a/public_html/js/cookies.js b/public_html/js/cookies.js index 790e8ef..7bf9dc3 100644 --- a/public_html/js/cookies.js +++ b/public_html/js/cookies.js @@ -1,10 +1,16 @@ function getCookie(name) { - nom = name + "="; - var liste = document.cookie.split (';'); - for (var i = 0; i < liste.length; i++) { - var c = liste[i]; - while (c.charAt(0) == ' ') c = c.substring(1, c.length); - if (c.indexOf(nom) == 0) return c.substring(nom.length, c.length); + let lookingFor = name + "="; + let arr = document.cookie.split(";"); + for(let str of arr) + { + while(str[0] == ' ') // removing potential unwanted spaces + { + str = str.slice(1); + } + if (str.slice(0,lookingFor.length)==lookingFor) + { + return str.slice(lookingFor.length); + } } return null; } \ No newline at end of file diff --git a/public_html/js/global.js b/public_html/js/global.js index 7bc917e..85a0619 100644 --- a/public_html/js/global.js +++ b/public_html/js/global.js @@ -4,6 +4,7 @@ let renderer = new Render("canvas"); let LB = new LeaderBoard("canvas"); let bulletSound = new Sound("./assets/sounds/shoot.mp3"); let driftSound = new Sound("./assets/sounds/drift.mp3"); +let dieSound = new Sound("./assets/sounds/die.mp3"); let notificationSound = new Sound("./assets/sounds/notification.mp3"); let net = new Network("wss://ws.gta6.insat.fr:8080?name=" + getCookie("pseudo")); let inp = new Input("canvas"); diff --git a/public_html/js/phone.js b/public_html/js/phone.js index f1cfbed..91d12e2 100644 --- a/public_html/js/phone.js +++ b/public_html/js/phone.js @@ -124,7 +124,7 @@ class Phone{ clearMessages(){ let messages = document.getElementsByClassName("message"); - for (var i = messages.length - 1; i >= 0; i--) { + for (let i = messages.length - 1; i >= 0; i--) { messages[i].remove(); } } diff --git a/server/objects.js b/server/objects.js deleted file mode 100644 index 3b37c86..0000000 --- a/server/objects.js +++ /dev/null @@ -1,3 +0,0 @@ -let objects = {"squares":[{"x":1162,"y":115,"w":144,"h":125},{"x":120,"y":906,"w":1228,"h":21},{"x":127,"y":0,"w":1225,"h":14},{"x":297,"y":114,"w":78,"h":93},{"x":169,"y":243,"w":62,"h":250},{"x":313,"y":243,"w":62,"h":253},{"x":228,"y":257,"w":96,"h":222},{"x":792,"y":113,"w":176,"h":126},{"x":1017,"y":113,"w":143,"h":81},{"x":1160,"y":241,"w":143,"h":-129},{"x":1065,"y":372,"w":127,"h":124},{"x":697,"y":372,"w":319,"h":126},{"x":697,"y":498,"w":159,"h":111},{"x":697,"y":628,"w":160,"h":158},{"x":1001,"y":628,"w":191,"h":158},{"x":281,"y":629,"w":175,"h":156},{"x":0,"y":0,"w":137,"h":616},{"x":0,"y":615,"w":136,"h":310},{"x":1337,"y":1,"w":130,"h":581},{"x":1337,"y":573,"w":131,"h":356},{"x":586,"y":153,"w":15,"h":24},{"x":651,"y":153,"w":12,"h":24},{"x":700,"y":187,"w":12,"h":22},{"x":1020,"y":194,"w":10,"h":47},{"x":1019,"y":227,"w":56,"h":14},{"x":1101,"y":227,"w":62,"h":13},{"x":654,"y":128,"w":105,"h":17},{"x":748,"y":129,"w":12,"h":49},{"x":748,"y":193,"w":12,"h":47},{"x":654,"y":223,"w":105,"h":16},{"x":521,"y":129,"w":106,"h":14},{"x":521,"y":140,"w":13,"h":38},{"x":521,"y":194,"w":13,"h":46},{"x":521,"y":225,"w":108,"h":16}],"circles":[{"x":552,"y":163,"r":13.601470508735444},{"x":608,"y":190,"r":20.248456731316587},{"x":569,"y":212,"r":11.704699910719626},{"x":680,"y":213,"r":12.041594578792296},{"x":727,"y":164,"r":14.212670403551895}]}; - -exports.objects = objects \ No newline at end of file diff --git a/server/server.js b/server/server.js index e8b9f80..23dd68f 100644 --- a/server/server.js +++ b/server/server.js @@ -48,7 +48,7 @@ function getUsername(req){ function createNewPlayer(socket, name) { let pos = generatePosition(); - var obj = { + let obj = { id: playerCount, x: pos[0], y: pos[1], @@ -91,7 +91,7 @@ function kick_player(player_id, socket, reason){ } function update(message, socket){ - for (var i = players.length - 1; i >= 0; i--) { + for (let i = players.length - 1; i >= 0; i--) { if(message.data.health <= MAX_HEALTH) { if (players[i].id == message.data.id) { players[i] = message.data; @@ -110,7 +110,7 @@ function newBullet(message, socket){ function died(message, socket){ broadcast(JSON.stringify(message), socket.id); - for (var i = players.length - 1; i >= 0; i--) { + for (let i = players.length - 1; i >= 0; i--) { if (players[i].id == message.data.id) { let pos = generatePosition(); @@ -127,7 +127,7 @@ function died(message, socket){ } function deletePlayer(socket){ - for (var i = players.length - 1; i >= 0; i--) { + for (let i = players.length - 1; i >= 0; i--) { broadcast(JSON.stringify({ type: "removePlayer", data: { diff --git a/server/testsite/app.js b/server/testsite/app.js index 1454825..4876789 100644 --- a/server/testsite/app.js +++ b/server/testsite/app.js @@ -1,5 +1,5 @@ const socket = new WebSocket('ws://localhost:8080?name=coucou'); //ws://129.151.227.50:9600 -var time = new Date(); +let time = new Date(); socket.addEventListener('open', (event) => { console.log('connecté'); }); diff --git a/tools/collidesTool/app.js b/tools/collidesTool/app.js index 4ef341c..15e7e4b 100644 --- a/tools/collidesTool/app.js +++ b/tools/collidesTool/app.js @@ -1,26 +1,26 @@ -var ctx = document.getElementById("canvas").getContext("2d"); -var cv = document.getElementById("canvas"); +let ctx = document.getElementById("canvas").getContext("2d"); +let cv = document.getElementById("canvas"); const fond = new Image(); fond.src = "../../public_html/assets/map/map11.jpg"; -var mapWidth = fond.width -var mapHeith = fond.height +let mapWidth = fond.width +let mapHeith = fond.height ctx.canvas.width = mapWidth ctx.canvas.height = mapHeith ctx.drawImage(fond, 0, 0, mapWidth, mapHeith); -var mode = "circle" +let mode = "circle" -var data = { +let data = { squares: [], circles: [] } -var start = [] -var stop = [] +let start = [] +let stop = [] -var w = [] +let w = [] cv.addEventListener("mousedown", (e)=>{ const rect = canvas.getBoundingClientRect(); @@ -42,7 +42,7 @@ cv.addEventListener("mouseup", (e)=>{ ctx.fillStyle = "#FF0000" ctx.fillRect(start[0], start[1], w[0], w[1]); }else if(mode=='circle'){ - var radius = Math.sqrt(w[0]**2 + w[1]**2); + let radius = Math.sqrt(w[0]**2 + w[1]**2); data.circles.push({ x: start[0], y:start[1], @@ -66,7 +66,7 @@ function rectMode(){ } function download(filename, text) { - var element = document.createElement('a'); + let element = document.createElement('a'); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); element.setAttribute('download', filename);