from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from .objects.Spectator import Spectator from .objects.Player import Player from .objects.Game import Game from . import config from time import sleep def routine(game: Game): while True: for player in game._updated_players: game.broadcast("update_paddle", player.to_dict(), [player]) game._updated_players.clear() if (game.started): game.ball.postion_x = game.ball.postion_x + game.ball.velocity_x game.ball.postion_y = game.ball.postion_y + game.ball.velocity_y game.broadcast("update_ball", game.ball.to_dict()) sleep(1 / config.SERVER_TPS)