artistic
December 12th, 2008, 10:25 AM
I am new to graphics programming. I am having a problem that the objects do not collide and seem to go over each other.I will paste my code so you can take a look and tell me what am I doing wrong.
I am using a bounding box. C# provides a structure name RECTANGLE.
private Image cheeseImage = null;
private Image breadImage = null;
private Rectangle cheeseRectangle;
private Rectangle breadRectangle;
//In Initialize component
System.Reflection.Assembly execAssem = System.Reflection.Assembly.GetExecutingAssembly();
cheeseImage = new System.Drawing.Bitmap(execAssem.GetManifestResourceStream(@"FirstMobileApp.cheese.gif"));
cheeseRectangle = new Rectangle(0, 0, cheeseImage.Width, cheeseImage.Height);
breadImage = new System.Drawing.Bitmap(execAssem.GetManifestResourceStream(@"FirstMobileApp.bread.gif"));
breadRectangle = new Rectangle(0, 0, breadRectangle.Width, breadRectangle.Height);
//And when I put the below code, it simply doesn't collides with the other object
if (cheeseRectangle.IntersectsWith(breadRectangle))
{
goingDown = !goingDown;
}
Any help would be appreciated
Thanks
I am using a bounding box. C# provides a structure name RECTANGLE.
private Image cheeseImage = null;
private Image breadImage = null;
private Rectangle cheeseRectangle;
private Rectangle breadRectangle;
//In Initialize component
System.Reflection.Assembly execAssem = System.Reflection.Assembly.GetExecutingAssembly();
cheeseImage = new System.Drawing.Bitmap(execAssem.GetManifestResourceStream(@"FirstMobileApp.cheese.gif"));
cheeseRectangle = new Rectangle(0, 0, cheeseImage.Width, cheeseImage.Height);
breadImage = new System.Drawing.Bitmap(execAssem.GetManifestResourceStream(@"FirstMobileApp.bread.gif"));
breadRectangle = new Rectangle(0, 0, breadRectangle.Width, breadRectangle.Height);
//And when I put the below code, it simply doesn't collides with the other object
if (cheeseRectangle.IntersectsWith(breadRectangle))
{
goingDown = !goingDown;
}
Any help would be appreciated
Thanks