#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include<Windows.h>
int main(void) {
char input;
int x, y, i, j;
x = 0;
y = 0;
printf("*");
while (1)
{
if ((input = getchar()) < 0) input = getchar();
switch (input)
{
case'w':
if (y > 0) y = y - 1;
break;
case'a':
if (x > 0) x = x - 1;
break;
case'd':
if (x < 100) x = x + 1;
break;
case's':
if (y < 100) y = y + 1;
break;
default:
break;
}
system("cls");
for (j = 0; j < y; j++)
printf("\n");
for (i = 0; i < x; i++)
printf(" ");
printf("*");
}
}
其中xy分别为横纵坐标