Screen.PixelScaleY and Screen.PixelScaleX should be removed and set to 1 (just search and replace the text with the number)
remove rsc.TEMP_MEMBLOCK and rsc.TEMP_MEMBLOCK2 and replace with your own constants indicating temporary memblocks.
This works - I tried it.
Scott
public unsafe static bool IsColliding(int image1, Rectangle r1, int image2, Rectangle r2)
{
Rectangle adjustedR1 = new Rectangle(r1.X * Screen.PixelScaleX, r1.Y * Screen.PixelScaleY, r1.Width * Screen.PixelScaleX, r1.Height * Screen.PixelScaleY);
Rectangle adjustedR2 = new Rectangle(r2.X * Screen.PixelScaleX, r2.Y * Screen.PixelScaleY, r2.Width * Screen.PixelScaleX, r2.Height * Screen.PixelScaleY);
Rectangle theIntersection = Rectangle.Intersect(adjustedR1, adjustedR2);
CDarkGDK.oDBMemBlock.MakeMemblockFromImage(rsc.TEMP_MEMBLOCK, image1);
CDarkGDK.oDBMemBlock.MakeMemblockFromImage(rsc.TEMP_MEMBLOCK2, image2);
uint* ptr1 = (uint*)CDarkGDK.oDBMemBlock.GetMemblockPtr(rsc.TEMP_MEMBLOCK);
uint* ptr2 = (uint*)CDarkGDK.oDBMemBlock.GetMemblockPtr(rsc.TEMP_MEMBLOCK2);
uint width1 = *(ptr1); // remember this value will be scaled
uint width2 = *(ptr2); // remember this value will be scaled
ptr1 += 3;
ptr2 += 3;
for (int y = theIntersection.Top; y < theIntersection.Bottom; y++)
{
for (int x = theIntersection.Left; x < theIntersection.Right; x++)
{
uint data1 = (*(ptr1 + (x - adjustedR1.X) + ((y - adjustedR1.Y) * width1)) & 0xFF000000) >> 24;
uint data2 = (*(ptr2 + (x - adjustedR2.X) + ((y - adjustedR2.Y) * width2)) & 0xFF000000) >> 24;
if (data1 > MIN_ALPHA_ALLOWED_BEFORE_COLLISION && data2 > MIN_ALPHA_ALLOWED_BEFORE_COLLISION )
{
CDarkGDK.oDBMemBlock.DeleteMemblock(rsc.TEMP_MEMBLOCK);
CDarkGDK.oDBMemBlock.DeleteMemblock(rsc.TEMP_MEMBLOCK2);
return true;
}
}
}
CDarkGDK.oDBMemBlock.DeleteMemblock(rsc.TEMP_MEMBLOCK);
CDarkGDK.oDBMemBlock.DeleteMemblock(rsc.TEMP_MEMBLOCK2);
return false;
}
Regards, Scott T.
Looking for mature software developer to finish my Bruce Lee remake.. apply via email to MSN address.