Game
- update trail size for mobile - change end message when is a tournament
This commit is contained in:
@ -6,13 +6,13 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/20 17:02:47 by edbernar #+# #+# */
|
||||
/* Updated: 2024/10/11 10:43:04 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/10/15 21:10:18 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
import * as THREE from '/static/javascript/three/build/three.module.js'
|
||||
import { map, opponent, player} from '/static/javascript/multiOnlineGame/multiOnlineGamePage.js'
|
||||
|
||||
import * as THREE from '/static/javascript/three/build/three.module.js'
|
||||
import { isMobile } from '/static/javascript/main.js'
|
||||
|
||||
class Ball
|
||||
{
|
||||
@ -287,7 +287,8 @@ class Ball
|
||||
this.updateTrail();
|
||||
}
|
||||
|
||||
updateTrail() {
|
||||
updateTrail()
|
||||
{
|
||||
const trailColors = trailGeometry.attributes.customColor.array;
|
||||
|
||||
for (let i = trailPositions.length - 3; i >= 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;
|
||||
}
|
||||
`;
|
||||
|
||||
|
Reference in New Issue
Block a user