Example #1
0
        public void PaddleHit(double diff)
        {
            double hypotenuse = Math.Sqrt(diff);
            double adjacent   = screenCenter.X - playerPaddle.center.X;
            double cosine     = adjacent / hypotenuse;

            angle = Math.PI / 2;  // + cosine*Math.PI/4;
            if (playerPaddle.center.X > 450)
            {
                angle += r.NextDouble() * .25;
            }
            else
            {
                angle -= r.NextDouble() * .25;
            }
            if (center.Y > 300)
            {
                velocityUp      = -r.Next(10) + 5;
                velocityAngled *= 1.33;
            }
            else
            {
                velocityUp = r.Next(6) + 20;
            }
            velocityAngled *= ((1 + r.NextDouble() * .3 - 0.15) + (double)(playerPaddle.power / 15));
            SoundFX.Pong();
        }
Example #2
0
 private void BounceUp()
 {
     if (!rolling)
     {
         velocityUp *= -1;
         velocityUp *= bounciness;
         SoundFX.Pong();
     }
     if (Math.Abs(velocityUp) < 1)
     {
         velocityUp = 0;
         rolling    = true;
     }
 }
Example #3
0
 public void EnemyPaddleHit()
 {
     angle = -Math.PI / 2;
     if (opponentPaddle.center.X < 450)
     {
         angle += r.NextDouble() * .25;
     }
     else
     {
         angle -= r.NextDouble() * .25;
     }
     if (center.Y > 300)
     {
         velocityUp      = -r.Next(10) + 5;
         velocityAngled *= 1.33;
     }
     else
     {
         velocityUp = r.Next(6) + 20;
     }
     velocityAngled *= (1 + r.NextDouble() * .2 - 0.1);
     SoundFX.Pong();
 }