From 4ceb61f8df7575d3cf080a7c9f6b89e4d2ee5699 Mon Sep 17 00:00:00 2001 From: Brandon <103316367+okbrandon@users.noreply.github.com> Date: Fri, 11 Oct 2024 18:07:09 +0200 Subject: [PATCH] game: Increasing ball speed at paddle hit --- backend/api/consumers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/api/consumers.py b/backend/api/consumers.py index c1e2f76f..0b20d523 100644 --- a/backend/api/consumers.py +++ b/backend/api/consumers.py @@ -718,12 +718,16 @@ async def run_match_loop(self, match_id): match_state['ball']['y'] - BALL_RADIUS <= match_state['playerA']['paddle_y'] + PADDLE_HEIGHT and # Ball's bottom is above paddle's bottom match_state['ball']['y'] + BALL_RADIUS >= match_state['playerA']['paddle_y'] - PADDLE_HEIGHT): # Ball's top is below paddle's top match_state['ball']['dx'] *= -1 + match_state['ball']['dx'] *= 1.1 + match_state['ball']['dy'] *= 1.1 await self.send_paddle_hit(match_state['playerA'], match_state['ball']) elif (match_state['ball']['x'] + BALL_RADIUS >= TERRAIN_WIDTH - PADDLE_WIDTH and # Right side of ball hits Player B's paddle match_state['ball']['y'] - BALL_RADIUS <= match_state['playerB']['paddle_y'] + PADDLE_HEIGHT and # Ball's bottom is above paddle's bottom match_state['ball']['y'] + BALL_RADIUS >= match_state['playerB']['paddle_y'] - PADDLE_HEIGHT): # Ball's top is below paddle's top match_state['ball']['dx'] *= -1 + match_state['ball']['dx'] *= 1.1 + match_state['ball']['dy'] *= 1.1 await self.send_paddle_hit(match_state['playerB'], match_state['ball']) # Check for scoring