标题:贪吃蛇的问题
只看楼主
相思雨
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-10-29
 问题点数:0 回复次数:0 
贪吃蛇的问题
一个很简单的贪吃蛇代码,想好好完善下,希望有高人帮下忙:
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)
搜索更多相关主题的帖子: 贪吃 
2008-10-29 20:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-241367-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.417234 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved