- Updating class
This commit is contained in:
Kum1ta
2024-08-22 14:36:27 +02:00
parent 0d79ce58ae
commit 49dec4d7e6
7 changed files with 63 additions and 18 deletions

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 diffBot = this.object.position.y - this.limits.down;
let speed = 0.25;
let speed = 0.15;
const slower = speed / 3;
if (diffBot > diffTop)

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 = [];
ballObject = null;
mapLength = 0;
banner = null;
centerPos = {
x: -1,
y: -1,
@ -56,7 +57,7 @@ class Map
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, true));
scene.add(this.#createBanner(10, 1))
this.#createBanner(10, 1);
if (obstacles)
this.#generateObstacle();
@ -211,9 +212,54 @@ class Map
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)
@ -317,7 +363,7 @@ class Map
{
const cylinder = this.arrObject[i].mesh.children[5];
const distance = ball.object.position.distanceTo(cylinder.position);
const speed = 0.1
const speed = 0.1;
if (distance < 0.25 && this.ballIsOnJumper.can)
{

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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)
{
if (!playerExist)
throw Error('Player need to be init before opponent.')
if (opponentExist)
throw Error("Opponent is already init.");
opponentExist = true;
@ -34,7 +32,7 @@ class Opponent
this.limits = map.limits;
this.object.position.set(0, 0.3, -map.mapLength / 2 + 0.2);
this.cleanup = new FinalizationRegistry((heldValue) => {
playerExist = false;
opponentExist = false;
})
this.cleanup.register(this, null);
}

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
- h : animation de point pour l'adversaire
- c : switch entre la vue du joueur et la vue de la caméra
- q : lancer animation sur les jumpers
- 8 : avance la balle
- 2 : recule la balle

View File

@ -1,25 +1,25 @@
{
"hash": "aeb97021",
"configHash": "0b4c6e74",
"hash": "b5ed7c4e",
"configHash": "4027b9ee",
"lockfileHash": "cd36b699",
"browserHash": "7877d18e",
"browserHash": "d0607953",
"optimized": {
"three": {
"src": "../../three/build/three.module.js",
"file": "three.js",
"fileHash": "25132e42",
"fileHash": "e1599062",
"needsInterop": false
},
"three/examples/jsm/Addons.js": {
"src": "../../three/examples/jsm/Addons.js",
"file": "three_examples_jsm_Addons__js.js",
"fileHash": "99fa9e6e",
"fileHash": "9f0a165c",
"needsInterop": false
},
"three/addons/loaders/GLTFLoader.js": {
"src": "../../three/examples/jsm/loaders/GLTFLoader.js",
"file": "three_addons_loaders_GLTFLoader__js.js",
"fileHash": "1e0e6771",
"fileHash": "13ce7c2e",
"needsInterop": false
}
},