debut de l'ajout des controles
This commit is contained in:
parent
e49f038573
commit
c4b97df0ff
31
main.c
31
main.c
@ -2,9 +2,6 @@
|
|||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define FG_WHITE_BG_WHITE "\x1b[38;5;255;48;5;255m"
|
#define FG_WHITE_BG_WHITE "\x1b[38;5;255;48;5;255m"
|
||||||
#define FG_136_BG_136 "\x1b[38;5;136;48;5;136m"
|
#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]) {
|
int print_tab(Pieces board[8][8]) {
|
||||||
for (int y = 0; y < 8; ++y) {
|
for (int y = 0; y < 8; ++y) {
|
||||||
for (int x = 0; x < 8; ++x) {
|
for (int x = 0; x < 8; ++x) {
|
||||||
@ -104,15 +102,25 @@ int a() {
|
|||||||
int y = 7;
|
int y = 7;
|
||||||
|
|
||||||
int input = getchar();
|
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) {
|
break;
|
||||||
case 104: // h
|
case 107: // k
|
||||||
case 106: // j
|
|
||||||
case 107: // k
|
break;
|
||||||
case 108: // l
|
case 108: // l
|
||||||
|
if (x != 7 || piece_color[y][x] == 1 || piece_color[y][x] == 2)
|
||||||
|
x++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
printf("%d", x);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,8 +158,9 @@ int main() {
|
|||||||
a();
|
a();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
getchar();
|
getchar();
|
||||||
printf("\x1b[10;0H"); // Déplacement du curseur juste en dessous du tableau de jeu
|
printf("\x1b[10;0H");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user