#include<stdio.h>
#include<windows.h>
#include<conio.h>//getch调用
void gotoxy(int x, int y)
{
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
int main()
{
gotoxy(10,10);
int c,x=10,y=10;
int i;
for(i=0;i>=0;i++)
{ c=getch();
if(c==‘w’)//由于是使用ascii码,可能有bug.
y–;
gotoxy(x,y);
if(c==‘a’)
x–;
gotoxy(x,y);
if(c==‘s’)
y++;
gotoxy(x,y);
if(c==‘d’)
x++;
}
return 0;
}
光标移动(新手向)
最新推荐文章于 2022-11-30 16:53:26 发布