I 'm trying to stop an object when it collide with an other. I mean if the user try to slide it on an other i want my object to slide and not to go over as it does for the moment. I'm using Xna and rectangle collision function.
public void Update(GameTime gametime)
{
Currentposition = Station.Position;
Station.Update();
coli = IsHit(ListObs[16].ShapeO, Station.Shape);
}
public void Draw(SpriteBatch spritebatch)
{
if (coli == true)
{
Station.Position = Currentposition;
Station.Draw(spritebatch);
}
else
{
Station.Draw(spritebatch);
}
}
its not working for the moment, i could try to use Farseer or bOx2DX but i think its too deep for me ( i don"t need gravity ).
public bool IsHit(Rectangle r1, Rectangle r2)
{
if (((r1.X + r1.Width >= r2.X) && (r1.X <= r2.X + r2.Width)) && ((r1.Y + r1.Height >= r2.Y) && (r1.Y <= r2.Y + r2.Height)))
return true;
else
return false;
}