Game
- Updating class
This commit is contained in:
BIN
site/real_game/blender/banner.blend
Normal file
BIN
site/real_game/blender/banner.blend
Normal file
Binary file not shown.
BIN
site/real_game/blender/exported/banner.glb
Normal file
BIN
site/real_game/blender/exported/banner.glb
Normal file
Binary file not shown.
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/20 17:02:47 by edbernar #+# #+# */
|
/* Created: 2024/08/20 17:02:47 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/08/22 00:04:30 by edbernar ### ########.fr */
|
/* Updated: 2024/08/22 14:28:34 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ class Ball
|
|||||||
{
|
{
|
||||||
let diffTop = this.limits.up - this.object.position.y;
|
let diffTop = this.limits.up - this.object.position.y;
|
||||||
let diffBot = this.object.position.y - this.limits.down;
|
let diffBot = this.object.position.y - this.limits.down;
|
||||||
let speed = 0.25;
|
let speed = 0.15;
|
||||||
const slower = speed / 3;
|
const slower = speed / 3;
|
||||||
|
|
||||||
if (diffBot > diffTop)
|
if (diffBot > diffTop)
|
||||||
|
@ -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/08/22 01:02:41 by edbernar ### ########.fr */
|
/* Updated: 2024/08/22 14:32:54 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -28,6 +28,7 @@ class Map
|
|||||||
arrObject = [];
|
arrObject = [];
|
||||||
ballObject = null;
|
ballObject = null;
|
||||||
mapLength = 0;
|
mapLength = 0;
|
||||||
|
banner = null;
|
||||||
centerPos = {
|
centerPos = {
|
||||||
x: -1,
|
x: -1,
|
||||||
y: -1,
|
y: -1,
|
||||||
@ -56,7 +57,7 @@ class Map
|
|||||||
scene.add(this.#createWall(3.5, 0.4, -length/2, "wallRight"));
|
scene.add(this.#createWall(3.5, 0.4, -length/2, "wallRight"));
|
||||||
scene.add(this.#createWallObstacle(1, 1, 1, false));
|
scene.add(this.#createWallObstacle(1, 1, 1, false));
|
||||||
scene.add(this.#createWallObstacle(-1, 1, 1, true));
|
scene.add(this.#createWallObstacle(-1, 1, 1, true));
|
||||||
scene.add(this.#createBanner(10, 1))
|
this.#createBanner(10, 1);
|
||||||
if (obstacles)
|
if (obstacles)
|
||||||
this.#generateObstacle();
|
this.#generateObstacle();
|
||||||
|
|
||||||
@ -211,9 +212,54 @@ class Map
|
|||||||
return (mesh);
|
return (mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
#createBanner(radius, height)
|
#createBanner(radius1, height1)
|
||||||
{
|
{
|
||||||
return (null);
|
const scene = this.scene;
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
const context = canvas.getContext('2d');
|
||||||
|
|
||||||
|
canvas.width = 512;
|
||||||
|
canvas.height = 512;
|
||||||
|
|
||||||
|
const centerX = canvas.width / 2;
|
||||||
|
const centerY = canvas.height / 2;
|
||||||
|
const radius = 150; // Rayon du cercle
|
||||||
|
|
||||||
|
// Définir le style du texte
|
||||||
|
context.font = '100px Arial';
|
||||||
|
context.fillStyle = 'white';
|
||||||
|
context.textAlign = 'center';
|
||||||
|
context.textBaseline = 'middle';
|
||||||
|
const text = "Hello, Three.js!";
|
||||||
|
|
||||||
|
for (let i = 0; i < text.length; i++) {
|
||||||
|
const angle = (i / text.length) * (2 * Math.PI);
|
||||||
|
context.save();
|
||||||
|
context.fillText(text[i], i * 100, 200);
|
||||||
|
context.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
const texture = new THREE.CanvasTexture(canvas);
|
||||||
|
|
||||||
|
texture.wrapS = THREE.RepeatWrapping;
|
||||||
|
texture.wrapT = THREE.RepeatWrapping;
|
||||||
|
|
||||||
|
texture.repeat.set(45, 1);
|
||||||
|
|
||||||
|
const material = new THREE.MeshBasicMaterial({ map: texture, side: THREE.DoubleSide });
|
||||||
|
|
||||||
|
canvas.innerHTML = 'Test';
|
||||||
|
loader.load( '../blender/exported/banner.glb', (gltf) => {
|
||||||
|
this.banner = gltf.scene.children[0];
|
||||||
|
this.banner.material = material;
|
||||||
|
this.banner.position.y += 1.7;
|
||||||
|
scene.add(gltf.scene);
|
||||||
|
setInterval(() => {
|
||||||
|
this.banner.rotation.y += 0.001;
|
||||||
|
}, 10);
|
||||||
|
}, undefined, function ( error ) {
|
||||||
|
console.error( error );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
#animationGravityChanger(group)
|
#animationGravityChanger(group)
|
||||||
@ -317,7 +363,7 @@ class Map
|
|||||||
{
|
{
|
||||||
const cylinder = this.arrObject[i].mesh.children[5];
|
const cylinder = this.arrObject[i].mesh.children[5];
|
||||||
const distance = ball.object.position.distanceTo(cylinder.position);
|
const distance = ball.object.position.distanceTo(cylinder.position);
|
||||||
const speed = 0.1
|
const speed = 0.1;
|
||||||
|
|
||||||
if (distance < 0.25 && this.ballIsOnJumper.can)
|
if (distance < 0.25 && this.ballIsOnJumper.can)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/21 10:34:49 by edbernar #+# #+# */
|
/* Created: 2024/08/21 10:34:49 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/08/21 14:38:44 by edbernar ### ########.fr */
|
/* Updated: 2024/08/22 10:46:18 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -25,8 +25,6 @@ class Opponent
|
|||||||
|
|
||||||
constructor (object, map)
|
constructor (object, map)
|
||||||
{
|
{
|
||||||
if (!playerExist)
|
|
||||||
throw Error('Player need to be init before opponent.')
|
|
||||||
if (opponentExist)
|
if (opponentExist)
|
||||||
throw Error("Opponent is already init.");
|
throw Error("Opponent is already init.");
|
||||||
opponentExist = true;
|
opponentExist = true;
|
||||||
@ -34,7 +32,7 @@ class Opponent
|
|||||||
this.limits = map.limits;
|
this.limits = map.limits;
|
||||||
this.object.position.set(0, 0.3, -map.mapLength / 2 + 0.2);
|
this.object.position.set(0, 0.3, -map.mapLength / 2 + 0.2);
|
||||||
this.cleanup = new FinalizationRegistry((heldValue) => {
|
this.cleanup = new FinalizationRegistry((heldValue) => {
|
||||||
playerExist = false;
|
opponentExist = false;
|
||||||
})
|
})
|
||||||
this.cleanup.register(this, null);
|
this.cleanup.register(this, null);
|
||||||
}
|
}
|
||||||
|
@ -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/08/22 00:53:14 by edbernar ### ########.fr */
|
/* Updated: 2024/08/22 10:48:29 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -27,6 +27,7 @@ Controls :
|
|||||||
- g : animation de point
|
- g : animation de point
|
||||||
- h : animation de point pour l'adversaire
|
- h : animation de point pour l'adversaire
|
||||||
- c : switch entre la vue du joueur et la vue de la caméra
|
- c : switch entre la vue du joueur et la vue de la caméra
|
||||||
|
- q : lancer animation sur les jumpers
|
||||||
|
|
||||||
- 8 : avance la balle
|
- 8 : avance la balle
|
||||||
- 2 : recule la balle
|
- 2 : recule la balle
|
||||||
|
Reference in New Issue
Block a user