Game
- remove video when user is on mobile Site - add skin in tournament request - fix bug with goal/bar selector
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/13 13:59:46 by edbernar #+# #+# */
|
||||
/* Updated: 2024/10/13 13:44:43 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/10/13 23:25:15 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -38,13 +38,15 @@ const availableGoals = [
|
||||
|
||||
class barSelecter
|
||||
{
|
||||
scene = null;
|
||||
renderer = null;
|
||||
camera = null;
|
||||
spotLight = new THREE.SpotLight(0xffffff, 5);
|
||||
selected = lastSelected ? lastSelected : availableSkins[0];
|
||||
bar = this.createBarPlayer(this.selected);
|
||||
boundChangeSkin = this.changeSkin.bind(this);
|
||||
scene = null;
|
||||
renderer = null;
|
||||
camera = null;
|
||||
spotLight = new THREE.SpotLight(0xffffff, 5);
|
||||
selected = lastSelected ? lastSelected : availableSkins[0];
|
||||
bar = this.createBarPlayer(this.selected);
|
||||
boundChangeSkin = this.changeSkin.bind(this);
|
||||
boundSkinSelector = this.resizeSelector.bind(this);
|
||||
div = null;
|
||||
|
||||
|
||||
constructor(div)
|
||||
@ -54,6 +56,7 @@ class barSelecter
|
||||
this.renderer = new THREE.WebGLRenderer({antialias: true});
|
||||
this.camera = new THREE.PerspectiveCamera(60, (pos.width - 10) / (pos.height - 10));
|
||||
|
||||
this.div = div;
|
||||
if (!lastSelected)
|
||||
lastSelected = availableSkins[0];
|
||||
this.scene.background = new THREE.Color(0x020202);
|
||||
@ -90,12 +93,15 @@ class barSelecter
|
||||
popup.removeEventListener('click', this.hideSkinSelector);
|
||||
popup.addEventListener('click', this.hideSkinSelector);
|
||||
});
|
||||
window.addEventListener('resize', () => {
|
||||
const pos = div.getBoundingClientRect();
|
||||
this.renderer.setSize(pos.width - 10, pos.height - 10);
|
||||
this.camera.aspect = (pos.width - 10) / (pos.height - 10);
|
||||
this.camera.updateProjectionMatrix();
|
||||
});
|
||||
window.addEventListener('resize', this.boundSkinSelector);
|
||||
}
|
||||
|
||||
resizeSelector()
|
||||
{
|
||||
const pos = this.div.getBoundingClientRect();
|
||||
this.renderer.setSize(pos.width - 10, pos.height - 10);
|
||||
this.camera.aspect = (pos.width - 10) / (pos.height - 10);
|
||||
this.camera.updateProjectionMatrix();
|
||||
}
|
||||
|
||||
hideSkinSelector(event)
|
||||
@ -181,6 +187,7 @@ class barSelecter
|
||||
}
|
||||
this.scene = null;
|
||||
actualBarSelecor = null;
|
||||
window.removeEventListener('resize', this.boundSkinSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,6 +206,7 @@ class goalSelecter
|
||||
boundChangeGoal = this.changeGoal.bind(this);
|
||||
boundhideGoalSelector = this.hideGoalSelector.bind(this);
|
||||
boundshowGoals = this.showGoals.bind(this);
|
||||
boundresizeSelector = this.resizeSelector.bind(this);
|
||||
|
||||
constructor(div)
|
||||
{
|
||||
@ -220,12 +228,15 @@ class goalSelecter
|
||||
this.renderer.setAnimationLoop(this.#loop.bind(this));
|
||||
div.removeEventListener('click', this.boundshowGoals);
|
||||
div.addEventListener('click', this.boundshowGoals);
|
||||
window.addEventListener('resize', () => {
|
||||
const pos = div.getBoundingClientRect();
|
||||
this.renderer.setSize(pos.width - 10, pos.height - 10);
|
||||
this.camera.aspect = (pos.width - 10) / (pos.height - 10);
|
||||
this.camera.updateProjectionMatrix();
|
||||
});
|
||||
window.addEventListener('resize', this.boundresizeSelector);
|
||||
}
|
||||
|
||||
resizeSelector()
|
||||
{
|
||||
const pos = this.div.getBoundingClientRect();
|
||||
this.renderer.setSize(pos.width - 10, pos.height - 10);
|
||||
this.camera.aspect = (pos.width - 10) / (pos.height - 10);
|
||||
this.camera.updateProjectionMatrix();
|
||||
}
|
||||
|
||||
showGoals()
|
||||
@ -379,6 +390,7 @@ class goalSelecter
|
||||
this.scene = null;
|
||||
actualGoalSelecter = null;
|
||||
this.div.removeEventListener('click', this.boundshowGoals);
|
||||
window.removeEventListener('resize', this.boundresizeSelector);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/22 17:08:46 by madegryc #+# #+# */
|
||||
/* Updated: 2024/10/12 17:08:11 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/10/14 21:45:07 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -17,6 +17,7 @@ import { LiveChat } from "/static/javascript/liveChat/main.js";
|
||||
import { sendRequest } from "/static/javascript/websocket.js";
|
||||
import { pageRenderer } from '/static/javascript/main.js'
|
||||
import { isMobile } from '/static/javascript/main.js';
|
||||
import { lastSelected } from '/static/javascript/lobbyPage/3d.js';
|
||||
|
||||
/*
|
||||
Information :
|
||||
@ -195,12 +196,12 @@ function startTournmament()
|
||||
let nbBot = document.getElementById('nbBot').value;
|
||||
|
||||
if (code != '')
|
||||
sendRequest("tournament", {action: 0, code: code});
|
||||
sendRequest("tournament", {action: 0, code: code, skin: lastSelected ? lastSelected.id : 0, goal: goalSelector ? goalSelector.selected : 0});
|
||||
else
|
||||
{
|
||||
nbBot = nbBot == '' ? 0 : nbBot;
|
||||
if (parseInt(nbBot) >= 0 && parseInt(nbBot) <= 7)
|
||||
sendRequest("tournament", {action: 0, code: '', nbBot: parseInt(nbBot)});
|
||||
sendRequest("tournament", {action: 0, code: '', nbBot: parseInt(nbBot), skin: lastSelected ? lastSelected.id : 0, goal: goalSelector ? goalSelector.selected : 0});
|
||||
else
|
||||
CN.new("Error", "You must enter a valid number of bot");
|
||||
}
|
||||
|
Reference in New Issue
Block a user