- fix bug resize 3d home page
    - fix bug selection on mobile mode in online game
This commit is contained in:
Kum1ta
2024-09-27 22:00:23 +02:00
parent 7d319d020b
commit 6f409e7476
5 changed files with 59 additions and 22 deletions

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */
/* Updated: 2024/09/27 21:15:45 by edbernar ### ########.fr */
/* Updated: 2024/09/27 21:54:19 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -812,31 +812,40 @@ class Map
}, 10);
};
listObject = null;
placeObject(listObject)
{
let nbJumper = 0;
this.listObject = listObject.content;
for (let i = 0; i < this.listObject.length; i++ )
listObject = listObject.content;
for (let i = 0; i < listObject.length; i++ )
{
if (this.listObject[i].type == 1)
if (listObject[i].type == 1)
{
this.#createGravityChanger(listObject[i].pos.x, listObject[i].pos.y, listObject[i].pos.z, "gravityChanger" + i, listObject[i].isUp ? "jumperTop" : "jumperBottom", listObject[i].isUp);
this.#createGravityChanger(listObject[i].pos.x, listObject[i].pos.y, listObject[i].pos.z, listObject[i].name, listObject[i].isUp ? "jumperTop" : "jumperBottom", listObject[i].isUp);
nbJumper++;
}
else if (this.listObject[i].type == 2)
scene.add(this.#createWallObstacle(this.listObject[i].pos.x, this.listObject[i].pos.y, this.listObject[i].pos.z, this.listObject[i].isUp));
else if (listObject[i].type == 2)
scene.add(this.#createWallObstacle(listObject[i].pos.x, listObject[i].pos.y, listObject[i].pos.z, listObject[i].isUp));
}
}
activeJumper(name)
{
ball.changeGravity();
if (this.listObject[index].isUp)
this.#animationGravityChanger(this.listObject[index].mesh, true);
else
this.#animationGravityChanger(this.listObject[index].mesh, false);
for (let i = 0; this.arrObject && i < this.arrObject.length; i++)
{
console.log("/////////////");
console.log(this.arrObject[i].name);
console.log(name);
console.log("/////////////");
if (this.arrObject[i].name == name)
{
if (this.arrObject[i].name == "jumperTop")
this.#animationGravityChanger(this.arrObject[i].mesh, true);
else
this.#animationGravityChanger(this.arrObject[i].mesh, false);
}
}
}
#generateObstacle()

View File

@ -6,11 +6,10 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */
/* Updated: 2024/09/27 21:16:32 by edbernar ### ########.fr */
/* Updated: 2024/09/27 21:21:02 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import { isMobile } from '/static/javascript/main.js'
import * as THREE from '/static/javascript/three/build/three.module.js'
/*
@ -71,8 +70,6 @@ class Player
this.opponent = opponent;
if (playerExist)
throw Error("Player is already init.");
if (isMobile)
showGamePad();
playerExist = true;
isOnPointAnim = false;
pressedButton = [];
@ -92,6 +89,11 @@ class Player
document.addEventListener('keypress', simplePressKey);
}
mobileMode()
{
showGamePad();
}
dispose()
{
playerExist = false;

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
/* Updated: 2024/09/27 21:05:41 by edbernar ### ########.fr */
/* Updated: 2024/09/27 21:21:29 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,7 +18,7 @@ import { sendRequest } from "/static/javascript/websocket.js";
import { Player } from '/static/javascript/multiOnlineGame/Player.js'
import { Map } from '/static/javascript/multiOnlineGame/Map.js'
import { Ball } from '/static/javascript/multiOnlineGame/Ball.js'
import { pageRenderer } from '/static/javascript/main.js'
import { pageRenderer, isMobile } from '/static/javascript/main.js'
import { Opponent } from '/static/javascript/multiOnlineGame/Opponent.js'
/*
@ -106,6 +106,8 @@ class MultiOnlineGamePage
document.body.appendChild(renderer.domElement);
renderer.domElement.setAttribute('id', 'canvasMultiGameOnline');
map.ballObject = ball.object;
if (isMobile)
player.mobileMode();
//////////////////////////
controls = new OrbitControls(cameraTmp, renderer.domElement)