0

I would like to add a Rect to IW2D so that I can do collision detection between two images. I created a struct Rect(x,y,width,height)

I'm rendering using the following code:

Transform.SetRot(Angle);
    Transform.ScaleRot(Scale);
    Transform.SetTrans(Position);
    Iw2DSetTransformMatrix(Transform);
    Iw2DSetColour(Colour);
    // Render image
    if (ShipBullet != 0)
        Iw2DDrawImage(ShipBullet, CIwFVec2(Position.x, Position.y));

    boundingRect.srcX = Position.x;
    boundingRect.SrcY = Position.y;

    Iw2DSetColour(0xff0000ff); // Set red
    Iw2DDrawRect(CIwFVec2(boundingRect.srcX, boundingRect.SrcY),
        CIwFVec2(boundingRect.Width, boundingRect.Height));

but I still don't know how to update boundingRect of the sprite. I added a debug code IW2DDrawRect to draw the bounding rect, but the rect doesn't bound the image, it's actually drawn somewhere else.

andre
  • 141
  • 1
  • 1
  • 9

1 Answers1

0

I'm not sure but it seems to me that applying the position in the transform and the image rendering will give you a double offset. But as long as the bounding rect x and y match the position the double offset should apply to both equally

FrankM
  • 772
  • 7
  • 11