- add rollback when user pos is not sync with serv
    - move player when player is out of bound
This commit is contained in:
Kum1ta
2024-10-22 16:19:19 +02:00
parent 9164f1a350
commit 458116cc97
2 changed files with 13 additions and 2 deletions

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */
/* Updated: 2024/10/15 21:12:25 by edbernar ### ########.fr */
/* Updated: 2024/10/22 16:14:43 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -110,6 +110,11 @@ class Player
showGamePad();
}
movePlayer(content)
{
this.object.position.x = content.pos;
}
dispose()
{
playerExist = false;
@ -371,12 +376,16 @@ class Player
this.object.position.x += this.speed * this.deltaTime;
if (!this.cameraFixed && !isOnPointAnim)
this.camera.position.x += this.speed * this.deltaTime;
if (this.object.position.x > this.limits.right)
this.object.position.x = this.limits.right;
}
if (pressedButton[i] == key.left && this.object.position.x > this.limits.left)
{
this.object.position.x -= this.speed * this.deltaTime;
if (!this.cameraFixed && !isOnPointAnim)
this.camera.position.x -= this.speed * this.deltaTime;
if (this.object.position.x < this.limits.left)
this.object.position.x = this.limits.left;
}
i++;
}