Game
- redirect if websocket is disconnect in gane Site - fix bug tv on homa page
This commit is contained in:
@ -6,13 +6,14 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/25 00:00:21 by edbernar #+# #+# */
|
/* Created: 2024/08/25 00:00:21 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/10/06 23:49:15 by edbernar ### ########.fr */
|
/* Updated: 2024/10/09 11:12:43 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
import { MultiOnlineGamePage } from "/static/javascript/multiOnlineGame/multiOnlineGamePage.js"
|
import { MultiOnlineGamePage } from "/static/javascript/multiOnlineGame/multiOnlineGamePage.js"
|
||||||
import { multiLocalGamePage } from "/static/javascript/multiLocalGame/multiLocalGamePage.js"
|
import { multiLocalGamePage } from "/static/javascript/multiLocalGame/multiLocalGamePage.js"
|
||||||
import { TournamentPage } from "/static/javascript/tournamentPage/TournamentPage.js"
|
import { TournamentPage } from "/static/javascript/tournamentPage/TournamentPage.js"
|
||||||
|
import { createNotification as CN } from "/static/javascript/notification/main.js";
|
||||||
import { settingsPage } from "/static/javascript/settingsPage/settingsPage.js"
|
import { settingsPage } from "/static/javascript/settingsPage/settingsPage.js"
|
||||||
import { WaitingGamePage } from "/static/javascript/waitingGame/main.js"
|
import { WaitingGamePage } from "/static/javascript/waitingGame/main.js"
|
||||||
import { ProfilPage } from "/static/javascript/profilPage/main.js";
|
import { ProfilPage } from "/static/javascript/profilPage/main.js";
|
||||||
@ -144,7 +145,15 @@ class Page
|
|||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
throw Error(error);
|
throw Error(error);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnect()
|
||||||
|
{
|
||||||
|
if (this.actualPage == MultiOnlineGamePage || this.actualPage == WaitingGamePage)
|
||||||
|
this.changePage('lobbyPage');
|
||||||
|
setTimeout(() => {
|
||||||
|
CN.new("Error", "Connection lost");
|
||||||
|
}, 1000)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/22 17:19:17 by edbernar #+# #+# */
|
/* Created: 2024/08/22 17:19:17 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/10/06 23:37:28 by edbernar ### ########.fr */
|
/* Updated: 2024/10/09 10:51:31 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -47,10 +47,11 @@ class Home3D
|
|||||||
|
|
||||||
static dispose()
|
static dispose()
|
||||||
{
|
{
|
||||||
document.addEventListener('scroll', mouseTracker);
|
document.removeEventListener('scroll', mouseTracker);
|
||||||
window.removeEventListener('resize', windowUpdater);
|
window.removeEventListener('resize', windowUpdater);
|
||||||
document.removeEventListener('mousemove', mouseTracker);
|
document.removeEventListener('mousemove', mouseTracker);
|
||||||
document.removeEventListener('click', redirection);
|
document.removeEventListener('click', redirection);
|
||||||
|
alreadRedirected = false;
|
||||||
|
|
||||||
if (!disable3D)
|
if (!disable3D)
|
||||||
{
|
{
|
||||||
@ -127,7 +128,7 @@ function home3D()
|
|||||||
scene.add(spotLight);
|
scene.add(spotLight);
|
||||||
spotLight.target = screen.screen;
|
spotLight.target = screen.screen;
|
||||||
|
|
||||||
if (Math.random() % 100 > 0.99)
|
if (Math.random() % 100 > 0.995)
|
||||||
video.pong = files.easterEggVideo;
|
video.pong = files.easterEggVideo;
|
||||||
putObject(files.lampModel, -2.5, 0, 2.5, 3, 0, Math.PI + Math.PI / 8, 0);
|
putObject(files.lampModel, -2.5, 0, 2.5, 3, 0, Math.PI + Math.PI / 8, 0);
|
||||||
putObject(files.plantModel, 1.5, 0, 3, 0.5, 0, 0, 0);
|
putObject(files.plantModel, 1.5, 0, 3, 0.5, 0, 0, 0);
|
||||||
@ -223,7 +224,7 @@ function home3D()
|
|||||||
{
|
{
|
||||||
raycaster.setFromCamera( mouse, camera );
|
raycaster.setFromCamera( mouse, camera );
|
||||||
const intersects = raycaster.intersectObjects( scene.children, false );
|
const intersects = raycaster.intersectObjects( scene.children, false );
|
||||||
|
|
||||||
if (!screen.canvasVideo)
|
if (!screen.canvasVideo)
|
||||||
{
|
{
|
||||||
composer.render();
|
composer.render();
|
||||||
@ -398,9 +399,13 @@ function redirection()
|
|||||||
}
|
}
|
||||||
moveCamera();
|
moveCamera();
|
||||||
}
|
}
|
||||||
|
let alreadRedirected = false;
|
||||||
|
|
||||||
function moveCamera()
|
function moveCamera()
|
||||||
{
|
{
|
||||||
|
if (alreadRedirected)
|
||||||
|
return ;
|
||||||
|
alreadRedirected = true;
|
||||||
const targetPosition = screen.tv.position;
|
const targetPosition = screen.tv.position;
|
||||||
const initialPosition = camera.position.clone();
|
const initialPosition = camera.position.clone();
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/31 22:17:24 by edbernar #+# #+# */
|
/* Created: 2024/07/31 22:17:24 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/10/08 03:12:29 by edbernar ### ########.fr */
|
/* Updated: 2024/10/09 11:03:11 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ import { typeChangePfp } from "/static/javascript/typeResponse/typeChangePfp.js"
|
|||||||
import { typeUserInfo } from "/static/javascript/typeResponse/typeUserInfo.js";
|
import { typeUserInfo } from "/static/javascript/typeResponse/typeUserInfo.js";
|
||||||
import { typeLogin } from "/static/javascript/typeResponse/typeLogin.js";
|
import { typeLogin } from "/static/javascript/typeResponse/typeLogin.js";
|
||||||
import { typeGame } from "/static/javascript/typeResponse/typeGame.js"
|
import { typeGame } from "/static/javascript/typeResponse/typeGame.js"
|
||||||
|
import { pageRenderer } from "/static/javascript/main.js";
|
||||||
|
|
||||||
let socket = null;
|
let socket = null;
|
||||||
let status = 0;
|
let status = 0;
|
||||||
@ -93,6 +94,8 @@ function launchSocket()
|
|||||||
socket.onclose = () => {
|
socket.onclose = () => {
|
||||||
status = 0;
|
status = 0;
|
||||||
console.log('Disconnected');
|
console.log('Disconnected');
|
||||||
|
if (pageRenderer)
|
||||||
|
pageRenderer.disconnect();
|
||||||
if (lastError != 9013)
|
if (lastError != 9013)
|
||||||
{
|
{
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -110,7 +113,6 @@ function sendRequest(type, content) {
|
|||||||
console.warn('Not connected');
|
console.warn('Not connected');
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
console.log(`Send request ${type} content: `, content);
|
|
||||||
if (content instanceof Object)
|
if (content instanceof Object)
|
||||||
coc = JSON.stringify(content);
|
coc = JSON.stringify(content);
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user