#include<stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <time.h>
void move(int x, int y)
{
COORD Cur;
Cur.X = x;
Cur.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Cur);
}
int main()
{
int n;
n=75;
for (int i=1; i<=n; i++)
{
for (int j=1; j<=n; j++)
{
if(j==1 || i==1 || i==n || j==n || i==j || i==n-j+1 || n/2+1==i || n/2+1==j)
printf("*");
else
printf(" ");
}
printf("\n");
}
int x=10,y=5;
char key;
move(x,y);
printf("┌┐");
srand(time(NULL)); // keep
int random=0,random2=0,random3=0;
random = rand()%75; // 0 ~99 사이의 수
random2 = rand()%75;
random3 = rand()%75;
printf("x :%2d y : %2d ",x,y);
printf("random : %2d",random);
while(1)
{
key = _getch();
move(x,y);
printf(" ");
if(key=='w')
{
y--;
if(y==random)
{
return 0;
}
if(y==random2)
{
return 0;
}
if(y==random3)
{
return 0;
}
}
else if(key=='a')
{
x--;
}
else if(key=='s')
{
y++;
if(y==random)
{
return 0;
}
if(y==random2)
{
return 0;
}
if(y==random3)
{
return 0;
}
}
else if(key=='d')
{
x++;
}
else if(key=='q')
{
printf("*");
}
if(x==5 && y==5)
{
return 0;
}
move(x,y);
printf("┌┐");
move(20,10);
printf("x :%2d y : %2d ",x,y);
printf("random : %2d",random);
printf("random2 : %2d",random);
printf("random3 : %2d",random);
}
}