蛇身的绘制代码-贪吃蛇游戏演示

时间:2024-05-13 20:48:42
【文件属性】:

文件名称:蛇身的绘制代码-贪吃蛇游戏演示

文件大小:952KB

文件格式:PPT

更新时间:2024-05-13 20:48:42

贪吃蛇

蛇身的绘制代码 CBrush brush(HS_DIAGCROSS, RGB(0,255,0)); pDC -> SelectObject(brush); pDC ->Rectangle(CRect(m_nLeft-1,m_nTop -1,m_nLeft + m_nWidth * m_nSize + 1,m_nTop + m_nHeight * m_nSize + 1) ); //画蛇的身体 CBrush brush1,brush2,brush3; brush1.CreateSolidBrush(RGB(255,0,0)); brush2.CreateSolidBrush(RGB(0,0,255)); brush3.CreateSolidBrush(RGB(0,255,0)); for (int i=0; i<= m_aBody.GetUpperBound () ; i++) { CPoint uPoint = m_aBody. GetAt (i); if(m_aBody.GetUpperBound () <10) pDC -> SelectObject(brush2); if(10SelectObject(brush3); if(20 SelectObject (brush1); pDC -> Rectangle (CRect (m_nLeft + uPoint.y *m_nSize, m_nTop + uPoint.x * m_nSize, m_nLeft + (uPoint. y + 1) * m_nSize, m_nTop + (uPoint. x + 1) * m_nSize) ); }


网友评论