主题:谁能帮我看下这个贪食蛇算法有什么问题?
void Snake::SnakeMove(HWND hwnd,HDC hdc)
{
HBRUSH hBrush;
RECT rect ;
int i ;
int a[50],b[50];
hBrush=CreateSolidBrush(GetBkColor(hdc));
SetRect(&rect,x[node-1],y[node-1],x[node-1]+10,y[node-1]+10);
FillRect(hdc,&rect,hBrush);
for(i=0;i<node;i++)
{
a[i]=x[i];
b[i]=y[i];
}
for(i=node-1;i>0;i--)
{
x[i]=x[i-1];
y[i]=y[i-1];
}
DirectionState();
for(i=0;i<node;i++)
{
hBrush=CreateSolidBrush(RGB(0,255,0));
SetRect(&rect,x[i],y[i],x[i]+10,y[i]+10);
FillRect(hdc,&rect,hBrush);
}
AddBody();
// ShowScore(hwnd,hdc);
DeleteObject(hBrush);
}
{
HBRUSH hBrush;
RECT rect ;
int i ;
int a[50],b[50];
hBrush=CreateSolidBrush(GetBkColor(hdc));
SetRect(&rect,x[node-1],y[node-1],x[node-1]+10,y[node-1]+10);
FillRect(hdc,&rect,hBrush);
for(i=0;i<node;i++)
{
a[i]=x[i];
b[i]=y[i];
}
for(i=node-1;i>0;i--)
{
x[i]=x[i-1];
y[i]=y[i-1];
}
DirectionState();
for(i=0;i<node;i++)
{
hBrush=CreateSolidBrush(RGB(0,255,0));
SetRect(&rect,x[i],y[i],x[i]+10,y[i]+10);
FillRect(hdc,&rect,hBrush);
}
AddBody();
// ShowScore(hwnd,hdc);
DeleteObject(hBrush);
}