小组作业二
emmm,我负责方向类,控制英雄移动。大佬说可以看看贪吃蛇代码找找思路,看了看表示还是不太懂怎么弄。我的代码如下:
#include <conio.h>
class move {
int x, y;
public:
move()
{
x = 1;
y = 1;
}
void direction();
};
void move::direction(){
while (1)
{
char ch = _getch();
if (ch == 65)
{
y--;
break;
}
else if (ch == 68)
{
y++;
break;
}
else if (ch == 87)
{
x--;
break;
}
else if (ch == 83)
{
x++;
break;
}
}
};