#include <windows.h> 

#include <stdio.h>

#include <conio.h>

#pragma warning (disable:4996)

void gotoxy(int x, int y);

void textcolor(int,int);

#define LIGHTRED 12

#define LIGHTBLUE 9

#define BLACK 0

#define WHITE 15

#define LIGHTGREEN 10

int main()

{

int sx, sy, ex, ey;

int width, lenght;

int i, j,k;

char ch;


while(1){

printf("시작 x,y 좌표를 입력하세요:n (x좌표는 1 이상 80이하 / y 좌표는 1 이상 24 이하) : ");

scanf("%d%d", &sx, &sy);

if(sx<1||sx>80||sy<1||sy>24)printf("다시입력하세요.n");

else break;}

while(1){

printf("끝 x,y 좌표를 입력하세요 n (x좌표는 %d 이상 80이하 / y 좌표는 %d 이상 24 이하) :", sx + 1, sy + 1);

scanf("%d%d", &ex, &ey);

if(ex<sx+1||ex>80||ey<sy+1||ey>24)printf("다시입력하세요.n");

else break;}


do

{

width = (ex - sx) + 1;

lenght = (ey - sy) + 1;


system("cls");

gotoxy(sx, sy);

for (i = 0; i < width; i++)

{

printf("*");

}

for(j = 0; j < lenght; j++)

{

gotoxy(sx,sy+j);

printf("*");

gotoxy(ex,sy+j);

printf("*");

}

gotoxy(sx,ey);

for(k = 1; k < width; k++)

{

printf("*");

}

gotoxy(sx,ey+3);

textcolor(WHITE,BLACK);

printf("[W:↑ S:↓ A:← D:→ // ESC:종료] n");


ch=getch();

if(ch=='W'||ch=='w')

{

if(sy==1);

else

sy--,ey--;

}

else if(ch=='S'||ch=='s')

{

if(sy==20);

else sy++,ey++;

}

else if(ch=='A'||ch=='a')

{

if(sx==1);

else sx--,ex--;

}

else if(ch=='D'||ch=='d')

{

if(sx==70);

else sx++,ex++;

}

}while(ch!=27);


return 0;

}

void gotoxy(int x, int y)

{

COORD Pos = { x - 1, y - 1 };

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos);

}

void textcolor(int foreground, int background) 

int color=foreground+background*16; 

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); 

}



===========================================================================================


처음 X,Y좌표랑 끝 X,Y좌표 받아서 사각형 출력하고 WASD 눌러서 이동하는 프로그램인데


벽에 붙으면 못뚫게 해놨는데 이걸 뚫을수 있게해서 


예를들면 포탈처럼 왼쪽으로 계속 밀면 오른쪽에서 나오게 할라고 하는데


어떻게 해야될까 ㅠㅜㅜ