#include<stdio.h>

#include<stdlib.h>

#include<iostream>

#include<Windows.h>

#include<conio.h>


using namespace std;


void map_build(int size);

void erase(int x, int y);

void gotoxy(int x, int y);

void move(char a);

void draw(char key);


int map[60][60] = {0};

int map_size;

int x = 2, y = 1;


int main(void)

{

    const int map_select[] = {8, 13, 19};

    int select;

    char key;


    

    while(1)

    {

    cout << "-Map Size-" << endl;

    cout << "1. Easy(8 * 8)" << endl << "2. Nomal(13 * 13)" << endl << "3. Hard(19 * 19)" << endl << ":  ";

    

    select = getchar() - '1';

    getchar();

        if(select >= 0 && select <= 2)

        {

            map_build(map_select[select]);

            break;

        }

    system("cls");

    }

    

    gotoxy(x,y);

    cout << "[]";

    do

    {

        if(_kbhit())

        {

            key = getch();

            gotoxy(x,y);

            if(map[x][y] == 0)

                cout << "  ";

            if(map[x][y] == 1)

                cout << "!!";

            if(map[x][y] == 2)

                cout << "??";


            draw(key);

            move(key);

            gotoxy(x,y);

            cout << "[]";

        }

    }while(key != 27);


    return 0;


}

void map_build(int size)

{

    map_size = size;


    system("cls");


    cout << "┏";

    for (int i = 0; i < size - 1; ++i) 

        cout << "━┳";

    cout << "━┓" << endl;


    for (int i = 0; i < size - 1; ++i)

    {

        cout << "┃";

        for (int j = 0; j < size - 1; ++j)

            cout << "  ┃";

        cout << "  ┃" << endl;


        cout << "┣";

        for(int j = 0; j < size - 1; ++j)

            cout << "━╋";

        cout << "━┫" << endl;

    }


    cout << "┃";

    for (int i = 0; i < size - 1; ++i)

        cout << "  ┃";

    cout << "  ┃" << endl;

    

    cout << "┗";

    for (int i = 0; i < size - 1; ++i)

        cout << "━┻";

    cout << "━┛" << endl;

}


void gotoxy(int x, int y)

{

COORD Pos;

Pos.X = x;

Pos.Y = y;

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Pos);

}

void move(char a)

{

    if(a == 72)  //up

    {

        y -= 2;

        if(y < 1) y = 1;

    }

    if(a == 80)  //down

    {

        y += 2;

        if(y > map_size * 2  - 1)

        {

            y = map_size * 2  - 1;      

        } 

    }

    if(a == 75)  //left

    {

        x -= 4;

        if(x < 1) x = 2;      

    }

    if(a == 77)  //right

        {

        x  += 4;     

            if(x > map_size * 4 - 2)

            x = map_size * 4 - 2;

        }

}

void draw(char key)

{

    if(key == 49)

        map[x][y] = 1;

    if(key == 50)

        map[x][y] = 2;

    if(key == 51)

        map[x][y] = 0;

}


programmer 너가 알려준건 아직 잘모르겠어 ㅠㅠ 근데 이것도 이것대로 괜찮지않아 ??