贪吃蛇的问题
一个很简单的贪吃蛇代码,想好好完善下,希望有高人帮下忙:void CQqView::MovePoint()
{
int x = 0, y = 0;
switch(m_nMoveType)
{
case 1:
x += 32;
break;
case 2:
x -= 32;
break;
case 3:
y -= 32;
break;
case 4:
y += 32;
break;
}
CPoint* pt = (CPoint*)m_pPointList.GetHead();
if (pt->x + x == m_nX && pt->y + y == m_nY)
{
CPoint* pNew = new CPoint(m_nX, m_nY);
m_pPointList.AddHead(pNew);
m_nPointNum ++;
CreateNewPoint();
return;
}
CDC* pDC = GetDC();
HICON hic = AfxGetApp()->LoadIcon(IDI_POINT);
HICON hicNULL = AfxGetApp()->LoadIcon(IDI_NULL);
if(m_nPointNum == 1)
{
pDC->DrawIcon(pt->x, pt->y, hicNULL);
pt->x += x;
pt->y += y;
pDC->DrawIcon(pt->x, pt->y, hic);
m_pPointList.SetAt(m_pPointList.GetHeadPosition(), pt);
}
else
{
CPoint* pLast = (CPoint*)m_pPointList.GetTail();
pDC->DrawIcon(pLast->x, pLast->y, hicNULL);
m_pPointList.RemoveTail();
delete pLast;
CPoint* pNew = new CPoint(pt->x + x, pt->y + y);
m_pPointList.AddHead(pNew);
pDC->DrawIcon(pNew->x, pNew->y, hic);
}
ReleaseDC(pDC);
}...
这只是其中一段,完整的见附件,能帮下的联系下我啦...QQ:271201968谢谢
贪吃蛇.rar
(41.53 KB)