/// <summary> /// Initializes a new instance of the <see cref="Ball"/> class. /// </summary> /// <param name="pongWorld">The pong world.</param> /// <param name="initialPosition">The initial position.</param> /// <param name="intialVelocity">The intial velocity.</param> public Ball(PongWorld pongWorld, Vector2 initialPosition, Vector2 intialVelocity) { this.pongWorld = pongWorld; this.position = initialPosition; this.velocity = intialVelocity; this.drawOrigin = new Vector2(Radius); }
/// <summary> /// Initializes a new instance of the <see cref="LeadPursuitPaddleController"/> class. /// </summary> /// <param name="pongWorld">The pong world.</param> /// <param name="paddle">The paddle.</param> public LeadPursuitPaddleController(PongWorld pongWorld, Paddle paddle) { this.paddle = paddle; this.pongWorld = pongWorld; this.previousExampleCount = 0; this.previousOpponentExampleCount = 0; }
/// <summary> /// Initializes a new instance of the <see cref="RandomPaddleController"/> class. /// </summary> public RandomPaddleController(PongWorld world, Paddle paddle) { this.pongWorld = world; this.paddle = paddle; this.paddleVelocity = 0; this.paddleAcceloration = 0; this.paddleJerk = 0; this.random = new Random(); }
/// <summary> /// Initializes a new instance of the <see cref="PongScreen"/> class. /// </summary> public PongScreen() : base() { int leftBuffer = 200; int topBuffer = 40; this.pongWorld = new PongWorld( new Rectangle(leftBuffer, topBuffer, 1920 - leftBuffer * 2, 1080 - topBuffer * 2), Settings.BallSpeed, Settings.UseRoundedPaddles, Settings.LeftPaddleAI, Settings.RightPaddleAI); }
/// <summary> /// Creates a new IPaddleController based on the specified /// pongWorld and paddle. The AI will be a random non-learner. /// </summary> /// <param name="pongWorld">The pong world.</param> /// <param name="paddle">The paddle.</param> /// <returns> /// The IPaddleController corresponding to the paddle. /// </returns> public static IPaddleController Create(PongWorld pongWorld, Paddle paddle) { int random = new Random().Next(3); switch (random) { case 0: return Create(pongWorld, AIType.PurePursuit, paddle); case 1: return Create(pongWorld, AIType.Random, paddle); case 2: return Create(pongWorld, AIType.LeadPursuit, paddle); } return null; }
/// <summary> /// Creates a new IPaddleController based on the specified /// pongWorld, aiType, and paddle. /// </summary> /// <param name="pongWorld">The pong world.</param> /// <param name="aiType">Type of the ai.</param> /// <param name="paddle">The paddle.</param> /// <returns> /// The IPaddleController corresponding to the paddle. /// </returns> public static IPaddleController Create(PongWorld pongWorld, AIType aiType, Paddle paddle) { switch (aiType) { case AIType.Human: return new HumanPaddleController(pongWorld, paddle); case AIType.PurePursuit: return new PurePursuitPaddleController(pongWorld, paddle); case AIType.LeadPursuit: return new LeadPursuitPaddleController(pongWorld, paddle); case AIType.Random: return new RandomPaddleController(pongWorld, paddle); } return null; }
/// <summary> /// Initializes a new instance of the <see cref="HumanPaddleController"/> class. /// </summary> public HumanPaddleController(PongWorld pongWorld, Paddle paddle) { this.pongWorld = pongWorld; this.paddle = paddle; }
/// <summary> /// Initializes a new instance of the <see cref="PurePursuitPaddleController"/> class. /// </summary> /// <param name="pongWorld">The pong world.</param> /// <param name="paddle">The paddle.</param> public PurePursuitPaddleController(PongWorld pongWorld, Paddle paddle) { this.paddle = paddle; this.pongWorld = pongWorld; }
/// <summary> /// Initializes a new instance of the <see cref="Paddle"/> class. /// </summary> /// <param name="pongWorld">The pong world.</param> /// <param name="initialPosition">The initial position.</param> /// <param name="isLeft">if set to <c>true</c> [is left].</param> public Paddle(IPaddleController controller, PongWorld pongWorld, Vector2 initialPosition, bool isLeft) { this.totalPositiveResponces = 0; this.totalResponces = 0; this.isLeftPaddle = isLeft; this.position = initialPosition; this.oldPosition = initialPosition; this.target = initialPosition.Y; this.pongWorld = pongWorld; this.drawOrigin = new Vector2(Width / 2f, Height / 2f); this.controller = controller; this.controller.paddle = this; this.PreviousStates = new List<PaddleState>(); }