add palyerhit request

This commit is contained in:
2024-09-30 15:37:55 +02:00
parent c5a5ef0539
commit cd4f9986f7
2 changed files with 8 additions and 8 deletions

View File

@ -6,7 +6,7 @@
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ # # By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2024/09/13 16:20:58 by tomoron #+# #+# # # Created: 2024/09/13 16:20:58 by tomoron #+# #+# #
# Updated: 2024/09/29 13:21:59 by edbernar ### ########.fr # # Updated: 2024/09/30 15:34:41 by tomoron ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -189,12 +189,8 @@ class Game:
socket.game = None socket.game = None
if (socket == self.p1): if (socket == self.p1):
self.left = 1 self.left = 1
if(self.p2 != None):
self.p2.sync_send({"type":"game","content":{"action":4}})
else: else:
self.left = 2 self.left = 2
if(self.p1 != None):
self.p1.sync_send({"type":"game","content":{"action":4}})
while(Game.waitingForPlayerLock): while(Game.waitingForPlayerLock):
time.sleeep(0.05) time.sleeep(0.05)
Game.waitingForPlayerLock = True Game.waitingForPlayerLock = True
@ -412,6 +408,8 @@ class Game:
velZ = self.speed - abs(velX) velZ = self.speed - abs(velX)
if(newBallPos[1] > 0): if(newBallPos[1] > 0):
velZ = -velZ velZ = -velZ
self.p1.sync_send({"type":"game","content":{"action":4, "is_opponent": newBallPos[1] < 0}})
self.p2.sync_send({"type":"game","content":{"action":4, "is_opponent": newBallPos[1] > 0}})
else: else:
await self.scoreGoal(1 if newBallPos[1] < 0 else 2) await self.scoreGoal(1 if newBallPos[1] < 0 else 2)
return; return;

View File

@ -6,7 +6,7 @@
# By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ # # By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2024/09/09 16:10:26 by tomoron #+# #+# # # Created: 2024/09/09 16:10:26 by tomoron #+# #+# #
# Updated: 2024/09/28 00:43:45 by tomoron ### ########.fr # # Updated: 2024/09/30 15:35:47 by tomoron ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -32,7 +32,8 @@ from .gameActions.ping import ping
# - pos # - pos
# - up # - up
# #
# 4 : leave : when the opponent left the game # 4: player hit
# is_opponent
# #
# 5 : ball_move : send new directtion/movement to the client # 5 : ball_move : send new directtion/movement to the client
# - pos : [x, z] # - pos : [x, z]
@ -52,7 +53,8 @@ from .gameActions.ping import ping
# 9: pong # 9: pong
# #
# 10: game end # 10: game end
# - won # - won : true/false
# - opponentLeft : true/false
#client actions (actions sent by the client) : #client actions (actions sent by the client) :
# 0 : start : starts a game # 0 : start : starts a game