ccmny

collide

Aug 11th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. public void Collide(PhysicalObject that)
  2.         {
  3.             if (new Rectangle(this.bounds.X + (int)this.speed.X,
  4.                               this.bounds.Y,
  5.                               this.bounds.Width + (int)this.speed.X,
  6.                               this.bounds.Height).Intersects(that.bounds))
  7.             {
  8.                 this.speed.X = 0;
  9.             }
  10.             else if (new Rectangle(this.bounds.X,
  11.                               this.bounds.Y + (int)this.speed.Y,
  12.                               this.bounds.Width,
  13.                               this.bounds.Height + (int)this.speed.Y).Intersects(that.bounds))
  14.             {
  15.                 this.speed.Y = 0;
  16.             }
  17.         }
Advertisement
Add Comment
Please, Sign In to add comment