/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Players.js :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: edbernar -limits) player1.position.z -= speed; else if (pressedButton[i] == 's' && player1.position.z < limits) player1.position.z += speed; else if (pressedButton[i] == 'ArrowUp' && player2.position.z > -limits) player2.position.z -= speed; else if (pressedButton[i] == 'ArrowDown' && player2.position.z < limits) player2.position.z += speed; i++; } } static changeColor(player, color) { player.material.color.set(color); } } function newBarPlayer(nbPlayer, color) { const geometry = new THREE.BoxGeometry(0.3, 0.4, 2.5); const material = new THREE.MeshPhysicalMaterial({color: color}); const mesh = new THREE.Mesh(geometry, material); mesh.castShadow = true; mesh.receiveShadow = true; if (nbPlayer == 1) mesh.position.set(-12, 0.4, 0); else mesh.position.set(12, 0.4, 0); return (mesh); } function addKeyInArr(e) { let i; i = 0; while (i < pressedButton.length && e.key != pressedButton[i]) i++; if (i == pressedButton.length) pressedButton.push(e.key); } function remKeyInArr(e) { let i; i = 0; while (i < pressedButton.length && e.key != pressedButton[i]) i++; if (i != pressedButton.length) pressedButton.splice(i, 1); } export { Players, player1, player2 };