Изменения в классе TBounce
class TBounce : public LfsaAppl
{
TBounce(CWnd* pW, int nNum, CSize sz,
LArc *pTBL=BounceTBL, int nPri = 1);
:
public:
COLORREF m_clrBall;
// Добавлено для задачи ?новобранцы?
void SetAddrMan (LFsaAppl *pFsaAppl);
CString cstrFace;
// лицо повернуто: Ф-прямо, Л-налево, П-направо
LFsaAppl *pFsaShot;
}
:.
TBounce::TBounce(CWnd* pW, int nNum, CSize sz, LArc *pTBL,
int nPri):
LFsaAppl(pTBL)
{
pParentWnd = pW;
pFsaMan = NULL;
m_clrBall = RGB(0,0,0);
cstrFace = ?Ф?; // стрелок — лицом во фронт
CDC* pDC = pParentWnd->GetDC();
m_ptPixel.x = pDC->GetDeviceCaps(ASPECTX);
m_ptPixel.y = pDC->GetDeviceCaps(ASPECTY);
pParentWnd->ReleaseDC(pDC);
SetNum(nNum);
Size(sz);
pApp = (CFireApp*)AfxGetApp();
FLoad(((CFireApp*)pApp)->pNetFsa,nPri);
}
void TBounce::SetAddrMan(LFsaAppl * pFsaAppl)
{ pFsaShot = pFsaAppl; }
void TBounce::MakeNewBall()
{
m_sizeTotal.cx =
(m_sizeRadius.cx + ABS(m_sizeMove.cx)) << 1;
m_sizeTotal.cy =
(m_sizeRadius.cy + ABS(m_sizeMove.cy)) << 1;
if (m_bmBall.m_hObject != NULL)
m_bmBall.DeleteObject(); // get rid of old bitmap
CClientDC dc(pParentWnd);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
m_bmBall.CreateCompatibleBitmap(&dc,
m_sizeTotal.cx, m_sizeTotal.cy);
ASSERT(m_bmBall.m_hObject != NULL);
CBitmap* pOldBitmap = dcMem.SelectObject(&m_bmBall);
// draw a rectangle in the background (window) color
CRect rect(0, 0, m_sizeTotal.cx, m_sizeTotal.cy);
CBrush brBackground(::GetSysColor(COLOR_WINDOW));
dcMem.FillRect(rect, &brBackground);
CBrush brCross(HS_DIAGCROSS, 0L);
CBrush* pOldBrush = dcMem.SelectObject(&brCross);
// вывод текста (новобранец повернут:
// Ф-прямо(фронт), Л-налево, П-направо)
dcMem.TextOut(0,0, cstrFace);
dcMem.SelectObject(pOldBrush);
dcMem.SelectObject(pOldBitmap);
dcMem.DeleteDC();
}