Game
- add key (p) to disable ads
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */
|
/* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */
|
||||||
/* Updated: 2024/11/19 16:35:13 by edbernar ### ########.fr */
|
/* Updated: 2024/11/20 14:37:03 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
/* 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/11/20 14:08:04 by edbernar ### ########.fr */
|
/* Updated: 2024/11/20 14:43:02 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
import { fetchProfile, MotionController } from '/static/javascript/three/examples/jsm/libs/motion-controllers.module.js'
|
import { fetchProfile, MotionController } from '/static/javascript/three/examples/jsm/libs/motion-controllers.module.js'
|
||||||
import { XRControllerModelFactory } from '/static/javascript/three/examples/jsm/webxr/XRControllerModelFactory.js'
|
import { XRControllerModelFactory } from '/static/javascript/three/examples/jsm/webxr/XRControllerModelFactory.js'
|
||||||
import { scene, renderer, isInVrMode, ball } from '/static/javascript/multiOnlineGame/multiOnlineGamePage.js'
|
import { scene, renderer, isInVrMode, ball, disablePublicity } from '/static/javascript/multiOnlineGame/multiOnlineGamePage.js'
|
||||||
import { lastSelectedGoal, availableGoals } from '/static/javascript/lobbyPage/3d.js';
|
import { lastSelectedGoal, availableGoals } from '/static/javascript/lobbyPage/3d.js';
|
||||||
import * as THREE from '/static/javascript/three/build/three.module.js'
|
import * as THREE from '/static/javascript/three/build/three.module.js'
|
||||||
import { layoutSelected } from '/static/javascript/lobbyPage/main.js'
|
import { layoutSelected } from '/static/javascript/lobbyPage/main.js'
|
||||||
@ -120,7 +120,7 @@ class Player
|
|||||||
this.mapVar.putVideoOnCanvas(3, 'goal');
|
this.mapVar.putVideoOnCanvas(3, 'goal');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.mapVar.putVideoOnCanvas(0, null);
|
this.mapVar.putVideoOnCanvas(0, null);
|
||||||
if (!isMobile && isOnChrome)
|
if (!isMobile && isOnChrome && !disablePublicity)
|
||||||
this.mapVar.putVideoOnCanvas(2, 3);
|
this.mapVar.putVideoOnCanvas(2, 3);
|
||||||
}, 4000);
|
}, 4000);
|
||||||
|
|
||||||
|
@ -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/11/19 18:25:40 by edbernar ### ########.fr */
|
/* Updated: 2024/11/20 14:57:08 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -38,6 +38,7 @@ let lastFpsDisplayed = 0;
|
|||||||
let lastFpsArr = [60];
|
let lastFpsArr = [60];
|
||||||
let VrButton = null;
|
let VrButton = null;
|
||||||
let isInVrMode = false;
|
let isInVrMode = false;
|
||||||
|
let disablePublicity = false;
|
||||||
|
|
||||||
const observer = new MutationObserver((mutationsList) => {
|
const observer = new MutationObserver((mutationsList) => {
|
||||||
mutationsList.forEach((mutation) => {
|
mutationsList.forEach((mutation) => {
|
||||||
@ -107,10 +108,9 @@ class MultiOnlineGamePage
|
|||||||
if (e.key == 'c')
|
if (e.key == 'c')
|
||||||
debug = !debug;
|
debug = !debug;
|
||||||
})
|
})
|
||||||
|
|
||||||
renderer.setAnimationLoop(loop)
|
renderer.setAnimationLoop(loop)
|
||||||
sendRequest('game', {action: 1});
|
sendRequest('game', {action: 1});
|
||||||
if (!isMobile && isOnChrome)
|
if (!isMobile && isOnChrome && !disablePublicity)
|
||||||
map.putVideoOnCanvas(2, 3);
|
map.putVideoOnCanvas(2, 3);
|
||||||
let lastPosition = player.object.position.x;
|
let lastPosition = player.object.position.x;
|
||||||
let lastUp = player.isUp;
|
let lastUp = player.isUp;
|
||||||
@ -129,6 +129,7 @@ class MultiOnlineGamePage
|
|||||||
lastPingTime = Date.now();
|
lastPingTime = Date.now();
|
||||||
}
|
}
|
||||||
}, 800);
|
}, 800);
|
||||||
|
document.addEventListener('keyup', tooglePublicity);
|
||||||
}
|
}
|
||||||
|
|
||||||
static dispose()
|
static dispose()
|
||||||
@ -141,6 +142,7 @@ class MultiOnlineGamePage
|
|||||||
map.putVideoOnCanvas(0, null);
|
map.putVideoOnCanvas(0, null);
|
||||||
VrButton = null;
|
VrButton = null;
|
||||||
window.removeEventListener('resize', windowUpdater);
|
window.removeEventListener('resize', windowUpdater);
|
||||||
|
document.removeEventListener('keyup', tooglePublicity);
|
||||||
if (interval)
|
if (interval)
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
interval = null;
|
interval = null;
|
||||||
@ -270,6 +272,25 @@ function windowUpdater()
|
|||||||
player.camera.updateProjectionMatrix();
|
player.camera.updateProjectionMatrix();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let tooglePublicityTimeout = null;
|
||||||
|
|
||||||
|
function tooglePublicity(event)
|
||||||
|
{
|
||||||
|
if (tooglePublicityTimeout)
|
||||||
|
clearTimeout(tooglePublicityTimeout);
|
||||||
|
tooglePublicityTimeout = setTimeout(() => {
|
||||||
|
if (event.key === 'p')
|
||||||
|
{
|
||||||
|
disablePublicity = !disablePublicity;
|
||||||
|
if (disablePublicity)
|
||||||
|
map.putVideoOnCanvas(0, null);
|
||||||
|
else
|
||||||
|
map.putVideoOnCanvas(2, 3);
|
||||||
|
tooglePublicityTimeout = null;
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
function loop()
|
function loop()
|
||||||
{
|
{
|
||||||
showFps();
|
showFps();
|
||||||
@ -280,7 +301,6 @@ function loop()
|
|||||||
renderer.render(scene, player.camera);
|
renderer.render(scene, player.camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function showFps()
|
function showFps()
|
||||||
{
|
{
|
||||||
const fps = document.getElementById('fps')
|
const fps = document.getElementById('fps')
|
||||||
@ -314,6 +334,8 @@ function vrMode()
|
|||||||
|
|
||||||
let xrReferenceSpace;
|
let xrReferenceSpace;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function configButton()
|
function configButton()
|
||||||
{
|
{
|
||||||
const newButton = document.createElement('button');
|
const newButton = document.createElement('button');
|
||||||
@ -361,4 +383,4 @@ function configButton()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export { MultiOnlineGamePage, player, opponent, ball, map, scene, renderer, isInVrMode, createBarPlayer };
|
export { MultiOnlineGamePage, player, opponent, ball, map, scene, renderer, isInVrMode, createBarPlayer, disablePublicity };
|
Reference in New Issue
Block a user