1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
// on recupre les images des 2 objets
Bitmap^ image1 = ControleurAffichage::GetInstance()->recupererTexture(obj1->GetTexture());
Bitmap^ image2 = ControleurAffichage::GetInstance()->recupererTexture(obj2->GetTexture());
// on recupere les rectangles des 2 objets
Rectangle rect1 = Rectangle(obj1->GetPosition(), obj1->GetDimensions());
Rectangle rect2 = Rectangle(obj2->GetPosition(), obj2->GetDimensions());
// on recupere le rectangle de collision
Rectangle rectIntersect = rect1;
rectIntersect.Intersect(rect2);
// on recupere les pixel de chq image compris dans ce rectangle de collision
BitmapData^ pixelsImage1 = image1->LockBits(
Rectangle(rectIntersect.X - obj1->GetPosition().X, rectIntersect.Y - obj1->GetPosition().Y, rectIntersect.Width, rectIntersect.Height),
ImageLockMode::ReadOnly, PixelFormat::Format32bppPArgb);
BitmapData^ pixelsImage2 = image2->LockBits(
Rectangle(rectIntersect.X - obj1->GetPosition().X, rectIntersect.Y - obj1->GetPosition().Y, rectIntersect.Width, rectIntersect.Height),
ImageLockMode::ReadOnly, PixelFormat::Format32bppPArgb);
// nombre de colonne
int stride = pixelsImage1->Stride;
// on recupere un pointeur vers le debut des pixels
IntPtr ptr1= pixelsImage1->Scan0;
IntPtr ptr2= pixelsImage2->Scan0; |
Partager