Paint food snake is no problem, is to draw the bomb to go has been an error,
//draw the snake's style
CPaintDC dc (this);
The CDC MemDC;
The CDC MemDC2;
CPen pen;
MemDC. SelectObject (& amp; Pen);
MemDC2. SelectObject (& amp; Pen);
CPen yspen;
Yspen. CreatePen (1, 1, RGB (255255255));//define the border around the white brush snake
MemDC. SelectObject (& amp; Yspen);
MemDC2. SelectObject (& amp; Yspen);
The CBrush ysbrush;
The CBrush ysbrush2;
//
{
Ysbrush. CreateSolidBrush (RGB (0255, 0));
MemDC. SelectObject (& amp; Ysbrush);
//draw the fruit
MemDC. A Rectangle (
CRect (10 + m_psFood. Y * 10,
120 + m_psFood. * 10 x,
10 + (m_psFood. Y + 1) * 10,
120 + (m_psFood. X + 1) * 10)
);
}
Ysbrush2. CreateSolidBrush (RGB (0, 0));
MemDC2. SelectObject (& amp; Ysbrush2);
//draw the bomb
MemDC2. A Rectangle (
CRect (10 + m_psBomb. Y * 10,
120 + m_psBomb. * 10 x,
10 + (m_psBomb. Y + 1) * 10,
120 + (m_psBomb. X + 1) * 10)
);
Dc. BitBlt (0, 0, 325, 425, & amp; MemDC, 0, 0, SRCCOPY);
}
CodePudding user response:
Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, double-click on the next line when don't understand, until can understand,CodePudding user response:
What are you doing the MemDC2 used?CodePudding user response:
MemDC and MemDC1 is not the same thing, that is to say, don't need MemDC1, what are you drawing other content, only need to change MemDC relationship with brush you want,CodePudding user response:
CPaintDC dc (this);The CDC MemDC;
The CDC MemDC2;
CPen yspen;
Yspen. CreatePen (1, 1, RGB (255255255));//define the border around the white brush snake
MemDC. SelectObject (& amp; Yspen);
MemDC2. SelectObject (& amp; Yspen);
CodePudding user response:
Haven't seen you MemDC2 CreateCompatibleBitmap or create a DIB bitmaps