Example #1
0
 void CollisionWithThePlayer(double nextX, double nextY, Player player)
 {
     double left = player.Left() + player.RealWidth() / 2.0, top = player.Top() + player.RealWidth() / 2.0;
     double radius2 = this.RealWidth() * this.RealWidth();
     double centerX = nextX + this.RealWidth() / 2.0, centerY = nextY + this.RealHeight() / 2.0;
     double dx = left - centerX, dy = top - centerY;
     if (!isCollisionPlayer && Math.Pow(dx, 2) + Math.Pow(dy, 2) <= radius2)
     {
         Velocity.X = -dx * Physics.ImpactPlayer;
         Velocity.Y = -dy * Physics.ImpactPlayer;
         isCollisionPlayer = true;
     }
     else
         isCollisionPlayer = false;
 }