public FourPlayerState(ContentManager Content)
        {
            player1 = new Paddle(Content.Load<Texture2D>("rodeSpeler"), Content.Load<Texture2D>("balRood"), new Vector2(0, 400), 350, Keys.W, Keys.S, true, "Player 1");
            player2 = new Paddle(Content.Load<Texture2D>("blauweSpeler"), Content.Load<Texture2D>("balBlauw"), new Vector2(Practicum1.Screen.X - 16, 400), 350, Keys.Up, Keys.Down, true, "Player 2");
            player3 = new Paddle(Content.Load<Texture2D>("geleSpeler"), Content.Load<Texture2D>("balGeel"), new Vector2(400, 0), 350, Keys.U, Keys.I, false, "Player 3");
            player4 = new Paddle(Content.Load<Texture2D>("groeneSpeler"), Content.Load<Texture2D>("balGroen"), new Vector2(400, Practicum1.Screen.Y - 16), 350, Keys.V, Keys.B, false, "Player 4");
            
            paddleList.Add(player1);
            paddleList.Add(player2);
            paddleList.Add(player3);
            paddleList.Add(player4);

            ball = new Ball(Content.Load<Texture2D>("bal"), new Vector2(Practicum1.Screen.X / 2, Practicum1.Screen.Y / 2), 275, paddleList, "Ball");
            
            powerUp1 = new PowerUp(null, new Vector2(0, 0), Content, "Powerup 1");
            powerUp2 = new PowerUp(null, new Vector2(0, 0), Content, "Powerup 2");
            
            powerUpList.Add(powerUp1);
            powerUpList.Add(powerUp2);

            pausedText = new TextObject("Game paused.", new Vector2(Practicum1.Screen.X / 2 - 80, Practicum1.Screen.Y / 2), Color.Black, null, "Pause Text");
            pausedText.Visible = false;

            
            this.Add(player1);
            this.Add(player2);
            this.Add(player3);
            this.Add(player4);
            this.Add(ball);
            this.Add(powerUp1);
            this.Add(powerUp2);
            this.Add(pausedText);
        }
 public AIPlayerState(ContentManager Content)
 {
     player1 = new Paddle(Content.Load<Texture2D>("rodeSpeler"), Content.Load<Texture2D>("balRood"), new Vector2(0, 300), 350, Keys.W, Keys.S, true, "Player 1");
     player2 = new PaddleAI(Content.Load<Texture2D>("blauweSpeler"), Content.Load<Texture2D>("balBlauw"), new Vector2(Practicum1.Screen.X - 15, 300), 350, true, "Player 2");
     paddleList.Add(player1);
     paddleList.Add(player2);
     ball = new Ball(Content.Load<Texture2D>("bal"), new Vector2(Practicum1.Screen.X / 2, Practicum1.Screen.Y / 2), 275, paddleList, "Ball");
     this.Add(player1);
     this.Add(player2);
     this.Add(ball);
     player2.Ball = ball;
 }
 public override void Update(GameTime gameTime)
 {
     winPaddle = Practicum1.WinPaddle;
     if(winText == null)
     {
         winText = new TextObject(winPaddle.Name + " has won! Press space to return to main menu", new Vector2(Practicum1.Screen.X / 2 - 200, Practicum1.Screen.Y - 150), Color.Black, null, "winText");
         this.Add(winText);
     }
     else
     {
         winText.Text = winPaddle.Name + " has won!\nPress space to return to main menu";
     }
 }
 public TrollState(ContentManager Content)
 {
     player1 = new Paddle(Content.Load<Texture2D>("rodeSpeler"), Content.Load<Texture2D>("balRood"), new Vector2(0, 300), 350, Keys.W, Keys.S, true, "Player 1");
     player2 = new Paddle(Content.Load<Texture2D>("blauweSpeler"), Content.Load<Texture2D>("balBlauw"), new Vector2(Practicum1.Screen.X - 15, 300), 350, Keys.Up, Keys.Down, true, "Player 2");
     paddleList.Add(player1);
     paddleList.Add(player2);
     for (int i = 0; i < 100; ++i)
     {
         ballarray[i] = new Ball(Content.Load<Texture2D>("bal"), new Vector2(Practicum1.Screen.X / 2 + 5 * i, Practicum1.Screen.Y / 2 + 5 * i), 275, paddleList, "Ball" + i);
         this.Add(ballarray[i]);
     }
     this.Add(player1);
     this.Add(player2);
 }
Esempio n. 5
0
 public void Reset(Paddle paddle)
 {
     position = new Vector2(Practicum1.Screen.X / 2, Practicum1.Screen.Y / 2);
     
     if (paddle.Name.Equals("Player 1"))
         direction = 0.75 * Math.PI + random.NextDouble() * 0.5 * Math.PI;
     else if (paddle.Name.Equals("Player 2"))
         direction = 0.25 * Math.PI - random.NextDouble() * 0.5 * Math.PI;
     else if (paddle.Name.Equals("Player 3"))
         direction = 0.25 * Math.PI + random.NextDouble() * 0.5 * Math.PI;
     else if (paddle.Name.Equals("Player 4"))
         direction = 0.75 * Math.PI - random.NextDouble() * 0.5 * Math.PI;
     lastBouncePaddle = null;
     speed = startSpeed;
 }
Esempio n. 6
0
 public void Bounce(Paddle paddle)
 {
     if(paddle.Name.Equals("Player 1"))
     {
         float relativeIntersectY = (paddle.Position.Y + ((paddle.Sprite.Height * paddle.SpriteScale) / 2) - position.Y);
         float normalizedIntersectY = (relativeIntersectY / ((paddle.Sprite.Height * paddle.SpriteScale) / 2));
         direction = normalizedIntersectY * (-1 * Math.PI / 3);
         
     }
     else if(paddle.Name.Equals("Player 2"))
     {
         float relativeIntersectY = (paddle.Position.Y + ((paddle.Sprite.Height * paddle.SpriteScale) / 2) - position.Y);
         float normalizedIntersectY = (relativeIntersectY / (paddle.Sprite.Height * paddle.SpriteScale) / 2); 
         direction = Math.PI - normalizedIntersectY * (-1 * Math.PI / 3);
     }
     else if(paddle.Name.Equals("Player 3"))
     {
         float relativeIntersectX = (paddle.Position.X + ((paddle.Sprite.Width * paddle.SpriteScale) / 2) - position.X);
         float normalizedIntersectX = (relativeIntersectX / (paddle.Sprite.Width * paddle.SpriteScale) / 2);
         direction = (0.5 * Math.PI) - normalizedIntersectX * (-2 * Math.PI / 3);
     }
     else if (paddle.Name.Equals("Player 4"))
     {
         float relativeIntersectX = (paddle.Position.X + ((paddle.Sprite.Width * paddle.SpriteScale) / 2) - position.X);
         float normalizedIntersectX = (relativeIntersectX / (paddle.Sprite.Width * paddle.SpriteScale) / 2);
         direction = (1.5 * Math.PI) + normalizedIntersectX * (-2 * Math.PI / 3);
     }
     lastBouncePaddle = paddle;
     speed *= 1.04;
 }