Quote:Original post by sspeedy
It's not a bad book
You're right, it's downright /horrible/. I would not ever recommend a Sam's book.
So, play by play breakdown:
int iXShrink = (
m_rcPosition.left - m_rcPosition.right) / 12;
left - right = width, assuming left > right, or -width, assuming right > left (more likely).
int iXShrink =
-width / 12;
Pretty self explanitory now, iXShrink = 1/12th the width of m_rcPosition.
int iYShrink = (
m_rcPosition.top - m_rcPosition.bottom) / 12;
Same thing here, only top - bottom = height, assuming top > bottom, or -height, assuming bottom > top ("screen coordinates", again, more likely).
int iYShrink =
-height / 12;
As this code would look using industry::retangle< int > (personal library):
int iXShrink = - m_rcPosition.width() / 12;
int iYShrink = - m_rcPosition.height() / 12;
Really weird to use a rectangle to directly store a position, though.
Next:
CopyRect(&m_rcCollision, &m_rcPosition);
Copies m_rcPosition to m_rcCollision. As the sane would write it:
m_rcCollision = m_rcPosition;
Betchya $20 that this compiles as-is with no other modifications to your code and does the exact same thing.
InflateRect(&m_rcCollision, iXShrink, iYShrink );
"Inflates"/grows the rectangle by 2*iXShrink and 2*iYShrink. Since these are negative, it really shrinks the rectangle. Equivilant to:
m_rcCollision.left -= iXShrink;
m_rcCollision.right += iXShrink;
m_rcCollision.top -= iYShrink;
m_rcCollision.bottom += iYShrink;
(assuming right > left && bottom > top).
Since i[X/Y]Shrink are negative, this means we're adding to left and subtracting from right (shrinking width), as well as adding to top and subtracting from bottom (shrinking height).