#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<conio.h>
using namespace std;
int map_size;
int board_size;
enum COLORG : int
{
c_none,
c_wall,
};
#define SCREEN_WIDTH 80
#define SCREEN_HEIGHT 25
int map[SCREEN_HEIGHT][SCREEN_WIDTH];
void build_map(int size)
{
board_size = size;
map_size = size * 2 + 1;
int cx = map_size / 2, cy = map_size / 2;
int r_sqr = cx * cx;
for(int y = 0; y < map_size; ++y)
{
for(int x = 0; x < map_size; ++x)
{
int d_sqr = (x - cx) * (x - cx) + (y - cy) * (y - cy);
map[y + 1][x + 1] = (d_sqr < r_sqr);
}
}
}
const char* patterns[] =
{
" ", " ", " ", "┏", " ", "┓", "━", "┳", " ", "┃", "┗", "┣", "┛", "┫", "┻", "╋",
};
void draw_map()
{
system("cls");
int y_set = 1;
int y_end = map_size + y_set;
int x_set = 1;
int x_end = map_size + x_set;
for(int y = y_set; y < y_end; ++y)
{
for(int x = x_set; x < x_end; ++x)
{
if(map[y][x] == c_wall) cout << patterns[((map[y - 1][x] & 1) << 3) | ((map[y][x - 1] & 1) << 2) |
((map[y][x + 1] & 1) << 1) | (map[y + 1][x] & 1)];
else cout << " ";
}
cout << endl;
}
}
int main()
{
build_map(11);
draw_map();
http://dblack.tk
커뮤니티 사이트 입니다 많은 이용 부탁 드립니다.