Esempio n. 1
0
File: Pad.cs Progetto: CSLU/Pong
 /// <summary>
 /// Check to see if the puck has collided with the pad, if so, reverse the pucks direction
 /// </summary>
 /// <param name="p">Puck object</param>
 public void checkCollisionAndRebound(Puck p)
 {
     if (this.bbox.Intersects(p.bbox))
     {
         if (!rebounding)
         {
             float diff = Math.Abs(p.Position.Y - this.Position.Y);
             float fulldiff = this.Size.Height;
             float speed = (((diff / fulldiff)) * p.SPEED) - p.SPEED / 2;
             p.flipX();
             p.setAngle(speed);
             rebounding = true;
         }
     }
     else
     {
         rebounding = false;
     }
 }