#include <stdio.h>
#include<math.h>
#include <time.h>
#include <windows.h>
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
void gotoxy(int x,int y)
{
COORD pos= {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void setColor(int x)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
}
int main()
{
char x;
int sx = 5, sy = 5, directX = 0, directY = 0,yju = 0,yjd = 0,a[101][101],b=4,i;
while(1)
{
// for(i=1;i<2;i++)
{
gotoxy(sx,sy);
printf(" ");
sx += directX;
sy += directY;
gotoxy(sx,sy);
printf("+");
if(kbhit())
{
x = getch();
switch(x)
{
case LEFT:
directX = -1;
directY=0;
a[1][1]=sx;
a[1][2]=sy;
//printf("LEFT");
break;
case RIGHT:
directX = 1;
directY=0;
a[1][1]=sx;
a[1][2]=sy;
//printf("RIGHT");
break;
case UP:
directY=-1;
directX=0;
a[1][1]=sx;
a[1][2]=sy;
break;
case DOWN:
directY=1;
directX=0;
a[1][1]=sx;
a[1][2]=sy;
break;
}
}
}
Sleep(100);
}
}