diff --git a/main.c b/main.c index e40cce6..b0d5d4a 100644 --- a/main.c +++ b/main.c @@ -2,9 +2,6 @@ #include #include #include -#include -#include -#include #define FG_WHITE_BG_WHITE "\x1b[38;5;255;48;5;255m" #define FG_136_BG_136 "\x1b[38;5;136;48;5;136m" @@ -74,6 +71,7 @@ int piece_color[8][8]; + int print_tab(Pieces board[8][8]) { for (int y = 0; y < 8; ++y) { for (int x = 0; x < 8; ++x) { @@ -104,15 +102,25 @@ int a() { int y = 7; int input = getchar(); + while (1) { + switch (input) { + case 104: // h + if (x != 0 || piece_color[y][x] == 1 || piece_color[y][x] == 2) + x--; + break; + case 106: // j - switch (input) { - case 104: // h - case 106: // j - case 107: // k - case 108: // l + break; + case 107: // k + + break; + case 108: // l + if (x != 7 || piece_color[y][x] == 1 || piece_color[y][x] == 2) + x++; + break; + } } - - + printf("%d", x); return 0; } @@ -150,8 +158,9 @@ int main() { a(); + getchar(); - printf("\x1b[10;0H"); // Déplacement du curseur juste en dessous du tableau de jeu + printf("\x1b[10;0H"); return 0; }