ajout du support des contrôles

This commit is contained in:
alberr_b0yyy 2025-06-12 10:29:38 +02:00
parent c4b97df0ff
commit fafb8aad4f

55
main.c
View File

@ -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 controls() {
while (1) {
int input = getchar();
while (1) {
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++;
break;
}
}
printf("%d", x);
}
else {
x = 0;
printf("%d", x);
}
break;
default: printf("sigma "); break;
}
}
return 0;
}
int piece_selecton() {
printf("\x1b[%d;%dh\x1b[39;49m", y, x);
}
int main() {