From da60f5fb16860561b4e0fd101d5285968dcea857 Mon Sep 17 00:00:00 2001 From: tarsovbak Date: Jun 10 2025 13:00:31 +0000 Subject: Print map on VT100 standart (colored) --- diff --git a/miner.c b/miner.c index 7d015aa..fc29a0c 100644 --- a/miner.c +++ b/miner.c @@ -12,7 +12,6 @@ int boty = 0; int botMines = 0; int bolocks = 0; char botCom[1]; - int width = 8; int height = 8; int mines = 10; @@ -38,13 +37,49 @@ void generatemap() { void printmap() { + printf("\e[1;1H\e[2J"); for (int d = 0; d < height; d++){ for (int e = 0; e < width; e++){ - printf("%c",screen[e][d]); + if(screen[e][d] == '-'){ + printf("\x1b[90;47m\033[%d;%dH%c",e,d,screen[e][d]); + } + if(screen[e][d] == '0'){ + printf("\x1b[90;47m\033[%d;%dH%c",e,d,screen[e][d]); + } + if(screen[e][d] == '1'){ + printf("\x1b[94;47m\033[%d;%dH%c",e,d,screen[e][d]); + } + if(screen[e][d] == '2'){ + printf("\x1b[32;47m\033[%d;%dH%c",e,d,screen[e][d]); + } + if(screen[e][d] == '3'){ + printf("\x1b[91;47m\033[%d;%dH%c",e,d,screen[e][d]); + } + if(screen[e][d] == '4'){ + printf("\x1b[34;47m\033[%d;%dH%c",e,d,screen[e][d]); + } + if(screen[e][d] == '5'){ + printf("\x1b[31;47m\033[%d;%dH%c",e,d,screen[e][d]); + } + if(screen[e][d] == '6'){ + printf("\x1b[36;47m\033[%d;%dH%c",e,d,screen[e][d]); + } + if(screen[e][d] == '7'){ + printf("\x1b[30;47m\033[%d;%dH%c",e,d,screen[e][d]); + } + if(screen[e][d] == '8'){ + printf("\x1b[90;47m\033[%d;%dH%c",e,d,screen[e][d]); + } + if(screen[e][d] == '^'){ + printf("\x1b[91;47m\033[%d;%dH%c",e,d,screen[e][d]); + } + if(screen[e][d] == '*'){ + printf("\x1b[30;47m\033[%d;%dH%c",e,d,screen[e][d]); + } } - printf("\n"); + //printf("\n"); } - printf("\n"); + printf("\x1b[0m\n"); } @@ -57,8 +92,8 @@ void gameover() { } } } - printf("GAME OVER!!!\n"); printmap(); + printf("GAME OVER!!!\n"); end=1; } @@ -113,7 +148,8 @@ void bot(){ } if (unknowns == 0) continue; - if (marks + unknowns == j) { + + if (unknowns+marks == j){ botCom[0] = 'm'; return; } @@ -125,6 +161,7 @@ void bot(){ } } + printf("random!\n"); botCom[0] = 'o'; while(1) { @@ -140,15 +177,15 @@ int main(){ scanf("%d %d %d",&width, &height, &mines); if (width > 1024){ width = 1024; - printf("Error Max Size is 1024"); + printf("Error Max Size is 1024\n"); } if (height > 1024){ height = 1024; - printf("Error Max Size is 1024"); + printf("Error Max Size is 1024\n"); } if (mines > width*height){ mines = width*height; - printf("Quantity of mines more than quantity of cell's"); + printf("Quantity of mines more than quantity of cell's\n"); } generatemap(); printf("On Bot(0/1)?: ");