Site/Game
- fix somes bugs
This commit is contained in:
@ -25,7 +25,7 @@ urlpatterns = [
|
||||
path("multiOnlineGamePage", views.multiOnlineGamePage, name='multiOnlineGamePage'),
|
||||
path("waitingGamePage", views.waitingGamePage, name='waitingGamePage'),
|
||||
path("profilPage", views.profilPage, name='profilPage'),
|
||||
# path("game", views.game, name='game'),
|
||||
path("game", views.game, name='game'),
|
||||
path("wait_game", views.game, name='wait_game'),
|
||||
path("tournament", views.tournament, name='tournament'),
|
||||
path("login42", views.login42, name='login42'),
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/25 00:00:21 by edbernar #+# #+# */
|
||||
/* Updated: 2024/10/01 23:03:17 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/10/06 15:31:59 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -50,6 +50,8 @@ class Page
|
||||
sendRequest("game", {action: 2});
|
||||
if (thisClass.actualPage == TournamentPage)
|
||||
sendRequest("tournament", {action: 1});
|
||||
if (thisClass.actualPage == WaitingGamePage)
|
||||
sendRequest("game", {action: 2});
|
||||
thisClass.changePage(thisClass.availablePages[i].name, true, arg, !thisClass.availablePages[i].suffix);
|
||||
return ;
|
||||
}
|
||||
|
@ -3,10 +3,10 @@
|
||||
/* ::: :::::::: */
|
||||
/* Ball.js :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: madegryc <madegryc@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/20 17:02:47 by edbernar #+# #+# */
|
||||
/* Updated: 2024/09/30 19:17:05 by madegryc ### ########.fr */
|
||||
/* Updated: 2024/10/06 15:57:46 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -44,17 +44,10 @@ class Ball
|
||||
{
|
||||
this.object = this.#createBall();
|
||||
this.centerPos = map.centerPos;
|
||||
this.centerPos.y += this.object.geometry.parameters.radius;
|
||||
this.centerPos.y = this.object.geometry.parameters.radius;
|
||||
this.limits = map.playerLimits;
|
||||
this.resetPosBall();
|
||||
scene.add(this.object);
|
||||
// this.world = new CANNON.World();
|
||||
// this.ballBody = new CANNON.Body({
|
||||
// shape: new CANNON.Sphere(0.15),
|
||||
// mass: 10,
|
||||
// });
|
||||
// this.ballBody.position.copy(this.object.position);
|
||||
// this.world.addBody(this.ballBody);
|
||||
}
|
||||
|
||||
#createBall()
|
||||
@ -71,7 +64,7 @@ class Ball
|
||||
|
||||
resetPosBall()
|
||||
{
|
||||
this.setPosition(this.centerPos.x, this.centerPos.y, this.centerPos.z);
|
||||
this.setPosition(this.centerPos.x, this.object.geometry.parameters.radius * 2, this.centerPos.z);
|
||||
}
|
||||
|
||||
resetScaleBall()
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */
|
||||
/* Updated: 2024/10/03 14:40:41 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/10/06 16:12:40 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -678,7 +678,8 @@ class Map
|
||||
clearInterval(interval2);
|
||||
interval2 = null;
|
||||
}
|
||||
scene.remove(this.banner);
|
||||
if (this.banner)
|
||||
scene.remove(this.banner);
|
||||
};
|
||||
|
||||
animationGoal(cordX, cordY, cordZ, nameObject, funcCreateObject)
|
||||
@ -714,6 +715,8 @@ class Map
|
||||
|
||||
#clearAnimationGoal()
|
||||
{
|
||||
if (!this.arrObject)
|
||||
return ;
|
||||
for (let i = 0; i < this.arrObject.length; i++)
|
||||
{
|
||||
if (this.arrObject[i].type == "goalObject")
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */
|
||||
/* Updated: 2024/10/05 02:41:30 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/10/06 16:15:27 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -194,32 +194,36 @@ class Player
|
||||
}, 10);
|
||||
|
||||
setTimeout(() => {
|
||||
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(() => {
|
||||
clearInterval(interval);
|
||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = null;
|
||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = 'fadeInGames 0.99s';
|
||||
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(0)';
|
||||
|
||||
setTimeout(() => {
|
||||
this.camera = tmp;
|
||||
this.object.material.color.copy(startColor);
|
||||
isOnPointAnim = false;
|
||||
if (!this.cameraFixed)
|
||||
{
|
||||
this.setCameraPosition(
|
||||
this.object.position.x,
|
||||
this.object.position.y - (this.object.position.y >= this.limits.up ? 0.7 : -0.7),
|
||||
this.object.position.z + 1.5
|
||||
);
|
||||
}
|
||||
if (interval)
|
||||
clearInterval(interval);
|
||||
interval = null;
|
||||
if (document.getElementsByTagName('canvas') && document.getElementsByTagName('canvas')[canvasIndex])
|
||||
{
|
||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = null;
|
||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = 'fadeOutGames 0.99s';
|
||||
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(1)';
|
||||
}, 400);
|
||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = 'fadeInGames 0.99s';
|
||||
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(0)';
|
||||
|
||||
setTimeout(() => {
|
||||
this.camera = tmp;
|
||||
this.object.material.color.copy(startColor);
|
||||
isOnPointAnim = false;
|
||||
if (!this.cameraFixed)
|
||||
{
|
||||
this.setCameraPosition(
|
||||
this.object.position.x,
|
||||
this.object.position.y - (this.object.position.y >= this.limits.up ? 0.7 : -0.7),
|
||||
this.object.position.z + 1.5
|
||||
);
|
||||
}
|
||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = null;
|
||||
document.getElementsByTagName('canvas')[canvasIndex].style.animation = 'fadeOutGames 0.99s';
|
||||
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(1)';
|
||||
}, 400);
|
||||
}
|
||||
}, 4000);
|
||||
}, 200)
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
|
||||
/* Updated: 2024/10/04 21:47:35 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/10/06 16:04:20 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -164,7 +164,6 @@ class MultiOnlineGamePage
|
||||
|
||||
renderer.setAnimationLoop(loop)
|
||||
sendRequest('game', {action: 1});
|
||||
|
||||
let lastPosition = player.object.position.x;
|
||||
let lastUp = player.isUp;
|
||||
interval = setInterval(() => {
|
||||
@ -254,7 +253,10 @@ class MultiOnlineGamePage
|
||||
let intervalEnd = null;
|
||||
let time = 4;
|
||||
|
||||
endGameScore.innerText = `${map.score.player} - ${map.score.opponent}`;
|
||||
if (!map)
|
||||
return ;
|
||||
if (map && map.score)
|
||||
endGameScore.innerText = `${map.score.player} - ${map.score.opponent}`;
|
||||
if (content.won)
|
||||
scoreText.innerText = "You win !"
|
||||
endGameDiv.style.display = 'flex';
|
||||
|
@ -3,10 +3,10 @@
|
||||
/* ::: :::::::: */
|
||||
/* typeGame.js :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/15 12:00:01 by edbernar #+# #+# */
|
||||
/* Updated: 2024/09/30 17:11:10 by hubourge ### ########.fr */
|
||||
/* Updated: 2024/10/06 15:32:02 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -39,7 +39,7 @@ function typeGame(content)
|
||||
opponent.movePlayer(content);
|
||||
else if (content.action == 4)
|
||||
player.scalePlayer(content.is_opponent);
|
||||
else if (content.action == 5)
|
||||
else if (content.action == 5 && ball)
|
||||
ball.updatePos(content);
|
||||
else if (content.action == 6)
|
||||
player.makeAnimation(content.is_opponent);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 13:29:50 by edbernar #+# #+# */
|
||||
/* Updated: 2024/10/05 03:02:38 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/10/06 15:32:04 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -57,7 +57,4 @@ function joinTournament(content)
|
||||
pageRenderer.changePage('tournamentPage', false, content.code);
|
||||
}
|
||||
|
||||
console.warn("Remove this : window.typeTournament = typeTournament;");
|
||||
window.typeTournament = typeTournament;
|
||||
|
||||
export { typeTournament };
|
Reference in New Issue
Block a user