Site/Game

- fix somes bugs
This commit is contained in:
Kum1ta
2024-10-06 16:25:45 +02:00
parent 58ae534e57
commit bcb10e8a36
8 changed files with 48 additions and 47 deletions

View File

@ -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'),

View File

@ -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 ;
}

View File

@ -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()

View File

@ -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,6 +678,7 @@ class Map
clearInterval(interval2);
interval2 = null;
}
if (this.banner)
scene.remove(this.banner);
};
@ -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")

View File

@ -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,12 +194,15 @@ 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(() => {
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 = 'fadeInGames 0.99s';
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(0)';
@ -220,6 +223,7 @@ class Player
document.getElementsByTagName('canvas')[canvasIndex].style.animation = 'fadeOutGames 0.99s';
document.getElementsByTagName('canvas')[canvasIndex].style.filter = 'brightness(1)';
}, 400);
}
}, 4000);
}, 200)
}

View File

@ -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,6 +253,9 @@ class MultiOnlineGamePage
let intervalEnd = null;
let time = 4;
if (!map)
return ;
if (map && map.score)
endGameScore.innerText = `${map.score.player} - ${map.score.opponent}`;
if (content.won)
scoreText.innerText = "You win !"

View File

@ -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);

View File

@ -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 };