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;
   }
  }
};

相关文章:

  • 2022-03-10
  • 2021-06-23
  • 2021-12-25
  • 2021-06-23
  • 2021-06-25
猜你喜欢
  • 2021-04-18
  • 2021-11-01
  • 2021-05-13
  • 2021-09-28
  • 2021-04-01
  • 2021-12-27
  • 2021-06-01
相关资源
相似解决方案