Exemplo n.º 1
0
Arquivo: Pad.cs Projeto: 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;
     }
 }