change ball direction after point

This commit is contained in:
2024-11-15 17:09:16 +01:00
parent 620bfed825
commit 3e2e8975fc
2 changed files with 5 additions and 4 deletions

View File

@ -6,7 +6,7 @@
# By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/11/13 16:21:18 by tomoron #+# #+# #
# Updated: 2024/11/13 16:30:41 by tomoron ### ########.fr #
# Updated: 2024/11/15 17:08:23 by tomoron ### ########.fr #
# #
# **************************************************************************** #
@ -276,7 +276,7 @@ class Game:
if(stop):
self.ball.vel = [0, 0]
else:
self.ball.setStartVel(self.lastWin == 2)
self.ball.setStartVel(self.lastWin == 1)
self.sendNewBallInfo(True)
self.gameStart = time.time()

View File

@ -6,7 +6,7 @@
# By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/10/05 03:22:32 by tomoron #+# #+# #
# Updated: 2024/10/22 15:35:59 by tomoron ### ########.fr #
# Updated: 2024/11/15 16:43:28 by tomoron ### ########.fr #
# #
# **************************************************************************** #
@ -40,12 +40,13 @@ class Player():
newPos = leftLimit if newPos < 0 else rightLimit
return(newPos)
print("speed :", abs(newPos - self.pos["pos"]) * (1 / deltaTime))
if(abs(newPos - self.pos["pos"]) * (1 / deltaTime) > GameSettings.maxPlayerSpeed + GameSettings.playerSpeedTolerance):
newMove = GameSettings.maxPlayerSpeed * deltaTime
if(newPos - self.pos["pos"] < 0):
newMove = -newMove
print("\033[31mplayer is too fast")
print("speed :", abs(newPos - self.pos["pos"]) * (1 / deltaTime))
print("time : ", deltaTime)
newPos = self.pos["pos"] + newMove
return(newPos)
print("no problem")