diff --git a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Ball.js b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Ball.js index d2c875e..cd85023 100644 --- a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Ball.js +++ b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Ball.js @@ -6,13 +6,13 @@ /* By: edbernar = 3; i--) @@ -297,31 +298,32 @@ class Ball trailPositions[2] = this.object.position.z; for (let i = 0; i < 33; i++) - trailSizes[i] = Math.max(0.5 * (1 - i / 33), 0.1); + { + if (isMobile) + trailSizes[i] = Math.max(0.2 * (1 - i / 33), 0.1); + else + trailSizes[i] = Math.max(0.5 * (1 - i / 33), 0.1); + } const velocityMagnitude = Math.sqrt( this.srvPos.vel[0] * this.srvPos.vel[0] + this.srvPos.vel[1] * this.srvPos.vel[1] ); - // Normalisation de la vitesse entre 0 (lente) et 1 (rapide) - const speedFactor = Math.min(velocityMagnitude / 10, 1); // Divisé par 10 pour ajuster l'échelle + const speedFactor = Math.min(velocityMagnitude / 10, 1); for (let i = 0; i < 33; i++) { const alpha = Math.max(1 - i / 33, 0); - // Couleur entre blanc et rouge selon la vitesse - const r = 1; // Rouge maximum - const g = 1 - speedFactor; // Moins de vert avec l'augmentation de la vitesse - const b = 1 - speedFactor; // Moins de bleu avec l'augmentation de la vitesse + const r = 1; + const g = 1 - speedFactor; + const b = 1 - speedFactor; - // Appliquer la couleur trailColors[i * 4] = r; trailColors[i * 4 + 1] = g; trailColors[i * 4 + 2] = b; trailColors[i * 4 + 3] = alpha; } - // Marquer les attributs comme nécessitant une mise à jour trailGeometry.attributes.position.needsUpdate = true; trailGeometry.attributes.size.needsUpdate = true; trailGeometry.attributes.customColor.needsUpdate = true; @@ -365,9 +367,9 @@ const vertexShader = ` `; const fragmentShader = ` - varying vec4 vColor; // Reçoit la couleur et l'alpha du vertex shader + varying vec4 vColor; void main() { - gl_FragColor = vColor; // Utilise la couleur avec l'alpha + gl_FragColor = vColor; } `; diff --git a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js index c2aa99a..aaf4c2c 100644 --- a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js +++ b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js @@ -6,7 +6,7 @@ /* By: edbernar { - const key = event.target.getAttribute("id"); + document.addEventListener('touchstart', addKeyTouch); + document.addEventListener('touchend', removeKeyTouch); +} - for (let i = 0; i < keyList.length; i++) - { - if (keyList[i] == key) - addKeyInArr({key: keyAction[i]}) - } - }); - document.addEventListener('touchend', (event) => { - const key = event.target.getAttribute("id"); +function addKeyTouch(event) +{ + const keyId = event.target.getAttribute("id"); + const keyAction = [key.left, key.right, key.up, key.down]; + const keyList = ['padLeft', 'padRight', 'padTop', 'padBottom']; - for (let i = 0; i < keyList.length; i++) - { - if (keyList[i] == key) - remKeyInArr({key: keyAction[i]}) - } - }); + console.log(key); + for (let i = 0; i < keyList.length; i++) + { + if (keyList[i] == keyId) + addKeyInArr({key: keyAction[i]}) + } +} + +function removeKeyTouch(event) +{ + const keyId = event.target.getAttribute("id"); + const keyAction = [key.left, key.right, key.up, key.down]; + const keyList = ['padLeft', 'padRight', 'padTop', 'padBottom']; + + for (let i = 0; i < keyList.length; i++) + { + if (keyList[i] == keyId) + remKeyInArr({key: keyAction[i]}) + } } export { Player, playerExist, goalAnimation}; diff --git a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js index 066078a..819c3b4 100644 --- a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js +++ b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js @@ -6,7 +6,7 @@ /* By: edbernar { if (content.opponentLeft) - simpleText.innerText = `Your opponent has given up...\nYou will be redirected to the lobby in ${time} seconds` + simpleText.innerText = `Your opponent has given up...\nYou will be redirected to the ` + content.tournamentCode ? "tournamenet" : "lobby" + ` in ${time} seconds` else - simpleText.innerText = `You will be redirected to the lobby in ${time} seconds` + simpleText.innerText = `You will be redirected to the ` + content.tournamentCode ? "tournamenet" : "lobby" + ` in ${time} seconds` time--; if (time == -1) {