ajout du support des contrôles
This commit is contained in:
parent
c4b97df0ff
commit
fafb8aad4f
53
main.c
53
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() {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user