xemerau

Deflection Issues

Jun 12th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1.         public void Deflection(Brick brick)
  2.         {
  3.  
  4.             if (!collided)
  5.             {
  6.                 //Inverting the Y direction if there is collision with the top or bottom of the brick
  7.                 if (position.Y <= brick.getPosition('Y') + brick.getPosition('H') || position.Y + texture.Height >= brick.getPosition('Y'))
  8.                     motion.Y *= -1;
  9.                 //Inverting the X direciton if there is collision with the right or left of the brick
  10.                 else if (position.X + texture.Width <= brick.getPosition('X') || position.X >= brick.getPosition('X') + brick.getPosition('W'))
  11.                     motion.X *= -1;
  12.  
  13.                 collided = true;
  14.             }
  15.         }
Advertisement
Add Comment
Please, Sign In to add comment