ajout du support des contrôles
This commit is contained in:
parent
c4b97df0ff
commit
fafb8aad4f
55
main.c
55
main.c
@ -68,8 +68,8 @@ int piece_color_to_str(Pieces piece) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int piece_color[8][8];
|
int piece_color[8][8];
|
||||||
|
int x = 1;
|
||||||
|
int y = 6;
|
||||||
|
|
||||||
|
|
||||||
int print_tab(Pieces board[8][8]) {
|
int print_tab(Pieces board[8][8]) {
|
||||||
@ -97,34 +97,61 @@ int print_tab(Pieces board[8][8]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int a() {
|
int controls() {
|
||||||
int x = 0;
|
while (1) {
|
||||||
int y = 7;
|
|
||||||
|
|
||||||
int input = getchar();
|
int input = getchar();
|
||||||
while (1) {
|
|
||||||
switch (input) {
|
switch (input) {
|
||||||
case 104: // h
|
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--;
|
x--;
|
||||||
|
printf("%d", x);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x = 7;
|
||||||
|
printf("%d", x);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 106: // j
|
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;
|
break;
|
||||||
case 107: // k
|
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;
|
break;
|
||||||
case 108: // l
|
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++;
|
x++;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("%d", x);
|
printf("%d", x);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x = 0;
|
||||||
|
printf("%d", x);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: printf("sigma "); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int piece_selecton() {
|
||||||
|
printf("\x1b[%d;%dh\x1b[39;49m", y, x);
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user