Minor fix

This commit is contained in:
hubourge
2024-11-11 18:14:27 +01:00
parent 280c66f5ca
commit bcea894e9f
3 changed files with 14 additions and 18 deletions

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* Map.js :+: :+: :+: */ /* Map.js :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/28 12:23:48 by edbernar #+# #+# */ /* Created: 2024/08/28 12:23:48 by edbernar #+# #+# */
/* Updated: 2024/11/11 10:26:38 by edbernar ### ########.fr */ /* Updated: 2024/11/11 18:02:49 by hubourge ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -27,7 +27,7 @@ let score = {player1: 0, player2: 0};
let onUpdate = false; let onUpdate = false;
let scoreElement = null; let scoreElement = null;
let initialSpeed = 0; let initialSpeed = 0;
let speed = 1; let speed = 0;
let gameEndStatus = false; let gameEndStatus = false;
const scoreToWin = 2; //+1 for real score to win const scoreToWin = 2; //+1 for real score to win
@ -54,7 +54,8 @@ class Map
wallTop = createWall(true); wallTop = createWall(true);
scene.add(wallTop); scene.add(wallTop);
initialSpeed = 0.2; initialSpeed = 0.15;
speed = 1;
if (Math.random() > 0.5) if (Math.random() > 0.5)
{ {
vec2.z = (Math.random() * 0.8 - 0.4) * initialSpeed; vec2.z = (Math.random() * 0.8 - 0.4) * initialSpeed;
@ -146,7 +147,7 @@ class Map
ball.position.x += vec2.x * speed; ball.position.x += vec2.x * speed;
ball.position.z += vec2.z * speed; ball.position.z += vec2.z * speed;
if (speed < 3) if (speed < 3)
speed += 0.005; speed += 0.0025;
// ball opacity // ball opacity
if (ball.position.x > 12.3) if (ball.position.x > 12.3)

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* multiLocalGamePage.js :+: :+: :+: */ /* multiLocalGamePage.js :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/28 12:07:39 by edbernar #+# #+# */ /* Created: 2024/08/28 12:07:39 by edbernar #+# #+# */
/* Updated: 2024/10/03 00:48:19 by edbernar ### ########.fr */ /* Updated: 2024/11/11 15:42:23 by hubourge ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -53,11 +53,6 @@ class multiLocalGamePage
camera.position.set(0, 22, 0); camera.position.set(0, 22, 0);
document.addEventListener('keypress', (e) => {
if (e.key == 'a')
Map.reCreate(true);
})
renderer.setAnimationLoop(loop); renderer.setAnimationLoop(loop);
document.body.style.opacity = 1; document.body.style.opacity = 1;
} }

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* Map.js :+: :+: :+: */ /* Map.js :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */ /* Created: 2024/08/20 14:52:55 by hubourge #+# #+# */
/* Updated: 2024/10/08 20:06:46 by edbernar ### ########.fr */ /* Updated: 2024/11/11 18:13:57 by hubourge ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -489,8 +489,8 @@ class Map
canvasImageLeft = document.createElement('canvas'); canvasImageLeft = document.createElement('canvas');
contextImageLeft = canvasImageLeft.getContext('2d'); contextImageLeft = canvasImageLeft.getContext('2d');
canvasImageLeft.width = 960; canvasImageLeft.width = 960 * 0.5;
canvasImageLeft.height = 960; canvasImageLeft.height = 960 * 0.5;
textureImageLeft = new THREE.CanvasTexture(canvasImageLeft); textureImageLeft = new THREE.CanvasTexture(canvasImageLeft);
textureImageLeft.imageSmoothingEnabled = false; textureImageLeft.imageSmoothingEnabled = false;
contextImageLeft.clearRect(0, 0, canvasImageLeft.width, canvasImageLeft.height); contextImageLeft.clearRect(0, 0, canvasImageLeft.width, canvasImageLeft.height);
@ -501,8 +501,8 @@ class Map
canvasImageRight = document.createElement('canvas'); canvasImageRight = document.createElement('canvas');
contextImageRight = canvasImageRight.getContext('2d'); contextImageRight = canvasImageRight.getContext('2d');
canvasImageRight.width = 960; canvasImageRight.width = 960 * 0.5;
canvasImageRight.height = 960; canvasImageRight.height = 960 * 0.5;
textureImageRight = new THREE.CanvasTexture(canvasImageRight); textureImageRight = new THREE.CanvasTexture(canvasImageRight);
contextImageLeft.clearRect(0, 0, canvasImageLeft.width, canvasImageLeft.height); contextImageLeft.clearRect(0, 0, canvasImageLeft.width, canvasImageLeft.height);