From fafb8aad4f649b7df4547485951e527be633649b Mon Sep 17 00:00:00 2001 From: alberr_b0yyy Date: Thu, 12 Jun 2025 10:29:38 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20du=20support=20des=20contr=C3=B4les?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.c | 53 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/main.c b/main.c index b0d5d4a..7c08c96 100644 --- a/main.c +++ b/main.c @@ -68,8 +68,8 @@ int piece_color_to_str(Pieces piece) { } int piece_color[8][8]; - - +int x = 1; +int y = 6; int print_tab(Pieces board[8][8]) { @@ -97,34 +97,61 @@ int print_tab(Pieces board[8][8]) { return 0; } -int a() { - int x = 0; - int y = 7; - - int input = getchar(); +int controls() { while (1) { + + int input = getchar(); + switch (input) { case 104: // h - if (x != 0 || piece_color[y][x] == 1 || piece_color[y][x] == 2) + if (x > 0 && (piece_color[y][x - 1] == 1 || piece_color[y][x - 1] == 2)) { x--; + printf("%d", x); + } + else { + x = 7; + printf("%d", x); + } break; case 106: // j - + if (y < 7 && (piece_color[y][x - 1] == 1 || piece_color[y][x - 1] == 2)) { + y++; + printf("%d", y); + } + else { + y = 0; + printf("%d", y); + } break; case 107: // k - + if (y > 0 && (piece_color[y][x - 1] == 1 || piece_color[y][x - 1] == 2)) { + y--; + printf("%d", y); + } + else { + y = 7; + printf("%d", y); + } break; case 108: // l - if (x != 7 || piece_color[y][x] == 1 || piece_color[y][x] == 2) + if (x < 7 && (piece_color[y][x - 1] == 1 || piece_color[y][x - 1] == 2)) { x++; + printf("%d", x); + } + else { + x = 0; + printf("%d", x); + } break; + default: printf("sigma "); break; } } - printf("%d", x); return 0; } - +int piece_selecton() { + printf("\x1b[%d;%dh\x1b[39;49m", y, x); +} int main() {