namespace PongGame.Hubs; /// /// Pong game state saving the positions of the paddles and the ball. /// The Pong board has aspect ratio 1:2 with height 500 and width 1000. /// public struct PongGameState { private const double HEIGHT = 500.0d; private const double WIDTH = 2 * HEIGHT; private const double PADDLE_LENGTH = HEIGHT / 10; private const double BALL_SPEED = 8; public static readonly PongGameState Initial = new() { BallPosition = PongBallPosition.Initial, P1Height = HEIGHT / 2, P2Height = HEIGHT / 2, P1Direction = PongPaddleDirection.Stop, P2Direction = PongPaddleDirection.Stop, Status = GameStatus.WaitingForPlayers }; public double P1Height { get; set; } public double P2Height { get; set; } public PongBallPosition BallPosition { get; set; } public GameStatus Status { get; set; } public PongPaddleDirection P1Direction { get; set; } public PongPaddleDirection P2Direction { get; set; } public struct PongBallPosition { public static readonly PongBallPosition Initial = new() { X = WIDTH / 2, Y = HEIGHT / 2 }; public double X { get; set; } public double Y { get; set; } } }