public void Update(GameTime gameTime, Paddle player, Paddle enemy) { if ((this.boundry.Intersects(player.Boundry) || this.boundry.Intersects(enemy.Boundry)) && ((this.boundry.Left + 3 > player.Boundry.Right) || (this.boundry.Right - 3 < enemy.Boundry.Left))) { this.velocity.X *= -1.0f; if ((this.velocity.X > -8) && (this.velocity.X < 8)) this.velocity *= 1.05f; } if (((this.boundry.Top <= 0) || (this.boundry.Bottom >= Game1.windowSize.Y)) && (this.boundry.Right < enemy.Boundry.Left)) { this.velocity.Y *= -1.0f; if ((this.velocity.Y > -8) && (this.velocity.Y < 8)) this.velocity *= 1.05f; } if (this.boundry.Left < 0) { if (resetTimer == 0) GameScreen.scoreComputer++; reset(gameTime); } else if (this.boundry.Right > Game1.windowSize.X) { if (resetTimer == 0) GameScreen.scorePlayer++; reset(gameTime); } cPosition += velocity; this.boundry = new Rectangle((int)cPosition.X, (int)cPosition.Y, (int)ballSize.X, (int)ballSize.Y); }
public GameOfPaddles(ConsoleHardwareConfig config) : base(config) { Hardware.LeftButton.Input.DisableInterrupt(); Hardware.RightButton.Input.DisableInterrupt(); Hardware.LeftButton.Input.OnInterrupt += OnLeftButtonClick; Hardware.RightButton.Input.OnInterrupt += OnRightButtonClick; Hardware.LeftButton.Input.EnableInterrupt(); Hardware.RightButton.Input.EnableInterrupt(); DisplaySplashScreen(); World = new Composition(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, ScreenSize, ScreenSize); Ball = new PlayerMissile("ball", 0, 0, World); LeftPaddle = new Paddle(Side.Left, this); RightPaddle = new Paddle(Side.Right, this); ResetBall(true); }
public GameOfPaddles(ConsoleHardwareConfig config) : base(config) { World = new Composition(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, ScreenSize, ScreenSize); Ball = new PlayerMissile { Name = "ball", Owner = World, IsEnemy = true }; LeftPaddle = new Paddle(Side.Left, this); RightPaddle = new Paddle(Side.Right, this); World.Coinc += (s, a, b) => { Ball.HorizontalSpeed = -Ball.HorizontalSpeed; return false; }; ResetBall(true); }