Game
- ball trail change color with speed = add goal id for opponnent
This commit is contained in:
@ -3,10 +3,10 @@
|
|||||||
# ::: :::::::: #
|
# ::: :::::::: #
|
||||||
# DummySocket.py :+: :+: :+: #
|
# DummySocket.py :+: :+: :+: #
|
||||||
# +:+ +:+ +:+ #
|
# +:+ +:+ +:+ #
|
||||||
# By: tomoron <marvin@42.fr> +#+ +:+ +#+ #
|
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/10/08 07:33:29 by tomoron #+# #+# #
|
# Created: 2024/10/08 07:33:29 by tomoron #+# #+# #
|
||||||
# Updated: 2024/10/10 19:25:49 by tomoron ### ########.fr #
|
# Updated: 2024/10/11 10:47:53 by edbernar ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ urlpatterns = [
|
|||||||
path("multiOnlineGamePage", views.multiOnlineGamePage, name='multiOnlineGamePage'),
|
path("multiOnlineGamePage", views.multiOnlineGamePage, name='multiOnlineGamePage'),
|
||||||
path("waitingGamePage", views.waitingGamePage, name='waitingGamePage'),
|
path("waitingGamePage", views.waitingGamePage, name='waitingGamePage'),
|
||||||
path("profilPage", views.profilPage, name='profilPage'),
|
path("profilPage", views.profilPage, name='profilPage'),
|
||||||
# path("game", views.game, name='game'),
|
path("game", views.game, name='game'),
|
||||||
path("wait_game", views.game, name='wait_game'),
|
path("wait_game", views.game, name='wait_game'),
|
||||||
path("tournament", views.tournament, name='tournament'),
|
path("tournament", views.tournament, name='tournament'),
|
||||||
path("login42", views.login42, name='login42'),
|
path("login42", views.login42, name='login42'),
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/20 17:02:47 by edbernar #+# #+# */
|
/* Created: 2024/08/20 17:02:47 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/10/07 14:10:52 by edbernar ### ########.fr */
|
/* Updated: 2024/10/11 10:43:04 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -287,11 +287,9 @@ class Ball
|
|||||||
this.updateTrail();
|
this.updateTrail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTrail() {
|
||||||
updateTrail()
|
|
||||||
{
|
|
||||||
const trailColors = trailGeometry.attributes.customColor.array;
|
const trailColors = trailGeometry.attributes.customColor.array;
|
||||||
|
|
||||||
for (let i = trailPositions.length - 3; i >= 3; i--)
|
for (let i = trailPositions.length - 3; i >= 3; i--)
|
||||||
trailPositions[i] = trailPositions[i - 3];
|
trailPositions[i] = trailPositions[i - 3];
|
||||||
trailPositions[0] = this.object.position.x;
|
trailPositions[0] = this.object.position.x;
|
||||||
@ -300,19 +298,35 @@ class Ball
|
|||||||
|
|
||||||
for (let i = 0; i < 33; i++)
|
for (let i = 0; i < 33; i++)
|
||||||
trailSizes[i] = Math.max(0.5 * (1 - i / 33), 0.1);
|
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
|
||||||
for (let i = 0; i < 33; i++) {
|
for (let i = 0; i < 33; i++) {
|
||||||
const alpha = Math.max(1 - i / 33, 0);
|
const alpha = Math.max(1 - i / 33, 0);
|
||||||
trailColors[i * 4] = 1.0 / Math.max(this.srvPos.vel[0] < 0 ? - this.srvPos.vel[0] : this.srvPos.vel[0], 0.3);
|
|
||||||
trailColors[i * 4 + 1] = 1.0 / Math.max(this.srvPos.vel[1] < 0 ? - this.srvPos.vel[1] : this.srvPos.vel[1], 0.3);
|
// Couleur entre blanc et rouge selon la vitesse
|
||||||
trailColors[i * 4 + 2] = 1.0 / Math.max((this.srvPos.vel[0] < 0 ? - this.srvPos.vel[0] : this.srvPos.vel[0]) + this.srvPos.vel[1] < 0 ? - this.srvPos.vel[1] : this.srvPos.vel[1], 0.3);
|
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
|
||||||
|
|
||||||
|
// Appliquer la couleur
|
||||||
|
trailColors[i * 4] = r;
|
||||||
|
trailColors[i * 4 + 1] = g;
|
||||||
|
trailColors[i * 4 + 2] = b;
|
||||||
trailColors[i * 4 + 3] = alpha;
|
trailColors[i * 4 + 3] = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Marquer les attributs comme nécessitant une mise à jour
|
||||||
trailGeometry.attributes.position.needsUpdate = true;
|
trailGeometry.attributes.position.needsUpdate = true;
|
||||||
trailGeometry.attributes.size.needsUpdate = true;
|
trailGeometry.attributes.size.needsUpdate = true;
|
||||||
trailGeometry.attributes.customColor.needsUpdate = true;
|
trailGeometry.attributes.customColor.needsUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dispose()
|
dispose()
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */
|
/* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/10/10 13:46:36 by edbernar ### ########.fr */
|
/* Updated: 2024/10/11 11:08:30 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -87,9 +87,7 @@ class Player
|
|||||||
pressedButton = [];
|
pressedButton = [];
|
||||||
console.log(layoutSelected);
|
console.log(layoutSelected);
|
||||||
key = {up: layoutSelected.US ? "w" : "z", down: "s", left: layoutSelected.US ? "a" : "q", right: "d"};
|
key = {up: layoutSelected.US ? "w" : "z", down: "s", left: layoutSelected.US ? "a" : "q", right: "d"};
|
||||||
console.warn("Remettre opponentGoal = availableGoals[goalIdOppenent] qaund le serveur le permettra");
|
this.opponentGoal = availableGoals[goalIdOppenent];
|
||||||
this.opponentGoal = availableGoals[0];
|
|
||||||
// opponentGoal = availableGoals[goalIdOppenent];
|
|
||||||
this.object = object;
|
this.object = object;
|
||||||
this.limits = map.playerLimits;
|
this.limits = map.playerLimits;
|
||||||
this.camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 10000);
|
this.camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 10000);
|
||||||
@ -266,8 +264,6 @@ class Player
|
|||||||
tmpCamera.fov -= 0.05;
|
tmpCamera.fov -= 0.05;
|
||||||
tmpCamera.updateProjectionMatrix();
|
tmpCamera.updateProjectionMatrix();
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
console.log("Oppenent : " + this.opponentGoal);
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
map.animationGoal(this.opponent.object.position.x, this.opponent.object.position.y, this.opponent.object.position.z, this.opponent.playerGoalAnimation, this.opponentGoal);
|
map.animationGoal(this.opponent.object.position.x, this.opponent.object.position.y, this.opponent.object.position.z, this.opponent.playerGoalAnimation, this.opponentGoal);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
|
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/10/10 13:47:22 by edbernar ### ########.fr */
|
/* Updated: 2024/10/11 10:56:51 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -86,6 +86,7 @@ class MultiOnlineGamePage
|
|||||||
{
|
{
|
||||||
static create(skin)
|
static create(skin)
|
||||||
{
|
{
|
||||||
|
console.log('skin', skin);
|
||||||
if (!skin)
|
if (!skin)
|
||||||
{
|
{
|
||||||
skin = {player: 4, opponent: 0};
|
skin = {player: 4, opponent: 0};
|
||||||
@ -108,7 +109,7 @@ class MultiOnlineGamePage
|
|||||||
|
|
||||||
vrMode();
|
vrMode();
|
||||||
opponent = new Opponent(bar2, map, Math.floor(Math.random() * 100 % 6));
|
opponent = new Opponent(bar2, map, Math.floor(Math.random() * 100 % 6));
|
||||||
player = new Player(bar1, map, opponent, Math.floor(Math.random() * 100 % 6), skin.goalId);
|
player = new Player(bar1, map, opponent, Math.floor(Math.random() * 100 % 6), skin.opponentGoaldId);
|
||||||
spotLight = new THREE.SpotLight(0xffffff, 10000, 0, 0.2);
|
spotLight = new THREE.SpotLight(0xffffff, 10000, 0, 0.2);
|
||||||
spotLight.castShadow = true;
|
spotLight.castShadow = true;
|
||||||
ambiantLight = new THREE.AmbientLight(0xffffff, 0.5);
|
ambiantLight = new THREE.AmbientLight(0xffffff, 0.5);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/09/14 21:20:45 by edbernar #+# #+# */
|
/* Created: 2024/09/14 21:20:45 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/10/08 17:48:27 by edbernar ### ########.fr */
|
/* Updated: 2024/10/11 10:54:35 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class WaitingGamePage
|
|||||||
timeout = setTimeout(() => {
|
timeout = setTimeout(() => {
|
||||||
document.body.style.animation = 'anim3 0.5s';
|
document.body.style.animation = 'anim3 0.5s';
|
||||||
document.body.style.opacity = 0;
|
document.body.style.opacity = 0;
|
||||||
pageRenderer.changePage("multiOnlineGamePage", false, {player: lastSelected ? lastSelected.id : 0, opponent: content.skin, opponentGoaldId: content.goalId, pfp: content.pfpSelf, pfpOpponent: content.pfpOpponent});
|
pageRenderer.changePage("multiOnlineGamePage", false, {player: lastSelected ? lastSelected.id : 0, opponent: content.skin, opponentGoaldId: content.goal, pfp: content.pfpSelf, pfpOpponent: content.pfpOpponent});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}, 500);
|
}, 500);
|
||||||
document.body.removeChild(returnButton);
|
document.body.removeChild(returnButton);
|
||||||
|
Reference in New Issue
Block a user