Site/Game

- goal selector finish | waiting for server
This commit is contained in:
Kum1ta
2024-10-03 14:51:07 +02:00
parent 61016cda28
commit 909104ce87
7 changed files with 115 additions and 90 deletions

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */
/* Updated: 2024/10/03 03:14:28 by edbernar ### ########.fr */
/* Updated: 2024/10/03 14:40:41 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -680,43 +680,14 @@ class Map
scene.remove(this.banner);
};
animationGoal(cordX, cordY, cordZ, nameObject)
animationGoal(cordX, cordY, cordZ, nameObject, funcCreateObject)
{
this.#clearAnimationGoal();
let objectList = [];
if (nameObject == "triangle")
{
for (let i = 0; i < 6; i++)
objectList.push(createTriangle(colorList[Math.floor(Math.random() * 100 % colorList.length)]));
}
else if (nameObject == "cylinder")
{
for (let i = 0; i < 6; i++)
objectList.push(createCylinder(colorList[Math.floor(Math.random() * 100 % colorList.length)]));
}
else if (nameObject == "star")
{
for (let i = 0; i < 6; i++)
objectList.push(createStar(colorList[Math.floor(Math.random() * 100 % colorList.length)]));
}
else if (nameObject == "box")
{
for (let i = 0; i < 6; i++)
objectList.push(createBox(colorList[Math.floor(Math.random() * 100 % colorList.length)]));
}
else if (nameObject == "rectangle")
{
for (let i = 0; i < 6; i++)
objectList.push(createRectangle(colorList[Math.floor(Math.random() * 100 % colorList.length)]));
}
else if (nameObject == "ring")
{
for (let i = 0; i < 6; i++)
objectList.push(createRing(colorList[Math.floor(Math.random() * 100 % colorList.length)]));
}
for (let i = 0; i < 6; i++)
objectList.push(funcCreateObject(colorList[Math.floor(Math.random() * 100 % colorList.length)]));
for (let i = 0; i < objectList.length; i++)
{
objectList[i].position.set(cordX, cordY, cordZ);

View File

@ -6,12 +6,13 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */
/* Updated: 2024/10/03 01:09:57 by edbernar ### ########.fr */
/* Updated: 2024/10/03 14:48:51 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import * as THREE from '/static/javascript/three/build/three.module.js'
import { layoutSelected } from '/static/javascript/lobbyPage/main.js'
import { lastSelectedGoal, availableGoals } from '/static/javascript/lobbyPage/3d.js';
/*
Explication du code :
@ -53,20 +54,21 @@ let key = null;
class Player
{
isUp = false;
object = null;
camera = null;
speed = 4;
cameraFixed = false;
interval = null;
limits = {};
previousTime = Date.now();
deltaTime = 1;
mapVar = null;
opponent = null;
isUp = false;
object = null;
camera = null;
speed = 4;
cameraFixed = false;
interval = null;
limits = {};
previousTime = Date.now();
deltaTime = 1;
mapVar = null;
opponent = null;
playerGoalAnimation = null;
opponentGoal = null;
constructor (object, map, opponent, indexGoalAnimation)
constructor (object, map, opponent, indexGoalAnimation, goalIdOppenent)
{
this.mapVar = map;
this.opponent = opponent;
@ -77,6 +79,9 @@ class Player
pressedButton = [];
console.log(layoutSelected);
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[0];
// opponentGoal = availableGoals[goalIdOppenent];
this.object = object;
this.limits = map.playerLimits;
this.camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 10000);
@ -180,7 +185,8 @@ class Player
}, 10);
setTimeout(() => {
map.animationGoal(this.object.position.x, this.object.position.y, this.object.position.z, this.playerGoalAnimation);
console.log("Player : " + lastSelectedGoal);
map.animationGoal(this.object.position.x, this.object.position.y, this.object.position.z, this.playerGoalAnimation, lastSelectedGoal ? lastSelectedGoal : availableGoals[0]);
}, 1000);
setTimeout(() => {
@ -241,9 +247,9 @@ class Player
tmpCamera.updateProjectionMatrix();
}, 10);
console.log("Oppenent : " + this.opponentGoal);
setTimeout(() => {
map.animationGoal(this.opponent.object.position.x, this.opponent.object.position.y,
this.opponent.object.position.z, this.opponent.playerGoalAnimation);
map.animationGoal(this.opponent.object.position.x, this.opponent.object.position.y, this.opponent.object.position.z, this.opponent.playerGoalAnimation, this.opponentGoal);
}, 1000);
setTimeout(() => {

View File

@ -3,14 +3,14 @@
/* ::: :::::::: */
/* multiOnlineGamePage.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
/* Updated: 2024/09/30 17:30:15 by hubourge ### ########.fr */
/* Updated: 2024/10/03 14:27:34 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import { availableSkins } from '/static/javascript/lobbyPage/3d.js';
import { availableSkins, lastSelectedGoal } from '/static/javascript/lobbyPage/3d.js';
import * as THREE from '/static/javascript/three/build/three.module.js'
import { OrbitControls } from '/static/javascript/three/examples/jsm/controls/OrbitControls.js'
import { sendRequest } from "/static/javascript/websocket.js";
@ -75,6 +75,7 @@ class MultiOnlineGamePage
{
static create(skin)
{
console.log(lastSelectedGoal);
if (!skin)
skin = {player: 0, opponent: 0};
const bar1 = createBarPlayer(availableSkins[skin.player]);
@ -89,7 +90,7 @@ class MultiOnlineGamePage
renderer.domElement.style.animation = 'fadeOutStartGames 1s';
renderer.domElement.style.filter = 'brightness(1)';
opponent = new Opponent(bar2, map, Math.floor(Math.random() * 100 % 6));
player = new Player(bar1, map, opponent, Math.floor(Math.random() * 100 % 6));
player = new Player(bar1, map, opponent, Math.floor(Math.random() * 100 % 6), skin.goalId);
spotLight = new THREE.SpotLight(0xffffff, 10000, 0, 0.2);
spotLight.castShadow = true;
ambiantLight = new THREE.AmbientLight(0xffffff, 0.5);