Ejemplo n.º 1
0
        public void Mov(Player player1, Player player2)
        {
            KeyboardState keyboardsState = Keyboard.GetState();

            if ((keyboardsState.IsKeyDown(Keys.W) ))
            {
                player1.Position.Y -= 5;
            }
            else if ((keyboardsState.IsKeyDown(Keys.S))) player1.Position.Y += 5;
            if ((keyboardsState.IsKeyDown(Keys.Up)))
            {
                player2.Position.Y -= 5;
            }
            else if ((keyboardsState.IsKeyDown(Keys.Down))) player2.Position.Y += 5;
        }
Ejemplo n.º 2
0
        public void CheckPlayerCollision(Player player, Player player2)
        {
            if ((Position.X < player.Position.X + player.Texture.Width) && (Position.Y > player.Position.Y) && (Position.Y < player.Position.Y + player.Texture.Height))
            {

                Velocity.X *= -1;

            }
            else if ((Position.X > player2.Position.X - player2.Texture.Width) && (Position.Y > player2.Position.Y) && (Position.Y < player2.Position.Y + player2.Texture.Height))
            {

                Velocity.X *= -1;

            }
        }