- update "update" in player class
This commit is contained in:
Kum1ta
2024-10-22 16:23:38 +02:00
parent 458116cc97
commit 69e0487181

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */ /* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */
/* Updated: 2024/10/22 16:14:43 by edbernar ### ########.fr */ /* Updated: 2024/10/22 16:23:11 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -377,7 +377,10 @@ class Player
if (!this.cameraFixed && !isOnPointAnim) if (!this.cameraFixed && !isOnPointAnim)
this.camera.position.x += this.speed * this.deltaTime; this.camera.position.x += this.speed * this.deltaTime;
if (this.object.position.x > this.limits.right) if (this.object.position.x > this.limits.right)
{
this.object.position.x = this.limits.right; this.object.position.x = this.limits.right;
this.camera.position.x = this.limits.right;
}
} }
if (pressedButton[i] == key.left && this.object.position.x > this.limits.left) if (pressedButton[i] == key.left && this.object.position.x > this.limits.left)
{ {
@ -385,7 +388,10 @@ class Player
if (!this.cameraFixed && !isOnPointAnim) if (!this.cameraFixed && !isOnPointAnim)
this.camera.position.x -= this.speed * this.deltaTime; this.camera.position.x -= this.speed * this.deltaTime;
if (this.object.position.x < this.limits.left) if (this.object.position.x < this.limits.left)
{
this.object.position.x = this.limits.left; this.object.position.x = this.limits.left;
this.camera.position.x = this.limits.left;
}
} }
i++; i++;
} }