- Add ball border transparence
    - Add others collision player on bottom and top
    - Fix ball velocity
This commit is contained in:
hubourge
2024-09-04 17:50:41 +02:00
parent 34f6ffc7c7
commit f016e411dc
4 changed files with 134 additions and 54 deletions

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* Players.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* By: hubourge <hubourge@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/28 15:12:25 by edbernar #+# #+# */
/* Updated: 2024/08/29 00:25:50 by edbernar ### ########.fr */
/* Updated: 2024/09/04 16:35:30 by hubourge ### ########.fr */
/* */
/* ************************************************************************** */
@ -40,13 +40,15 @@ class Players
static update()
{
const limits = 4.55;
const limits = 4.55;
let i = 0;
while (i < pressedButton.length)
{
if (pressedButton[i] == 'w' && player1.position.z > -limits)
player1.position.z -= speed;
if (pressedButton[i] == 'z' && player1.position.z > -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)
@ -54,7 +56,7 @@ class Players
else if (pressedButton[i] == 'ArrowDown' && player2.position.z < limits)
player2.position.z += speed;
i++;
}
}
}
}
@ -95,4 +97,4 @@ function remKeyInArr(e)
pressedButton.splice(i, 1);
}
export { Players, player1, player2 };
export { Players, player1, player2 };