game: online: limit max ball speed

This commit is contained in:
starnakin 2024-05-15 12:35:18 +02:00
parent 54edc080ab
commit 96c99a6f2d
2 changed files with 2 additions and 1 deletions

View File

@ -11,6 +11,7 @@ MAP_CENTER_Y = MAP_SIZE_Y / 2
WALL_RATIO = 1
BALL_SPEED_MAX = 550
BALL_SPEED_INC = 50
BALL_SPEED_START = 170
BALL_SIZE = 4

View File

@ -274,7 +274,7 @@ async def update_ball(game: PongGame, impact_data: dict):
await asyncio.sleep(0.1) # create frontend animation
await SyncToAsync(game.goal)(ret)
else:
game.ball.speed += config.BALL_SPEED_INC
game.ball.speed = min(game.ball.speed + config.BALL_SPEED_INC, config.BALL_SPEED_MAX)
game.ball.position.location = impact_data.get("impact")
#game.ball.position.time = time.time() * 1000
game.ball.angle = ret