je sais pas frère
This commit is contained in:
parent
63ccaf6a12
commit
0d5f77d2c4
115
main.c
115
main.c
@ -65,7 +65,7 @@ int piece_color_to_int(Pieces piece) {
|
||||
}
|
||||
|
||||
Pieces board[8][8] = {
|
||||
{BLACK_ROOK, EMPTY, BLACK_BISHOP, EMPTY, EMPTY, BLACK_ROOK, BLACK_KING, EMPTY},
|
||||
{EMPTY, EMPTY, BLACK_BISHOP, EMPTY, EMPTY, BLACK_ROOK, BLACK_KING, EMPTY},
|
||||
{BLACK_PAWN, BLACK_PAWN, BLACK_PAWN, EMPTY, BLACK_PAWN, BLACK_PAWN, BLACK_PAWN, BLACK_PAWN},
|
||||
{EMPTY, BLACK_KNIGHT, EMPTY, BLACK_PAWN, EMPTY, EMPTY, EMPTY, EMPTY},
|
||||
{EMPTY, EMPTY, EMPTY, EMPTY, WHITE_PAWN, BLACK_KNIGHT, EMPTY, EMPTY},
|
||||
@ -149,6 +149,95 @@ void a() {
|
||||
while (1){}
|
||||
}
|
||||
|
||||
void controls() {
|
||||
while (1) {
|
||||
tile_selection();
|
||||
|
||||
x_direction = 0;
|
||||
y_direction = 0;
|
||||
|
||||
switch (getchar()) {
|
||||
case 104: // h
|
||||
if (x == 0 && y == 0) {
|
||||
x = 7;
|
||||
y = 7;
|
||||
x_direction = 7;
|
||||
y_direction = 7;
|
||||
}
|
||||
if (x > 0) {
|
||||
for (x--; x > 0; x--) {
|
||||
x_direction--;
|
||||
if (piece_color_to_int(board[y][x]) == 1 || piece_color_to_int(board[y][x]) == 2) {
|
||||
break;
|
||||
}
|
||||
if (piece_color_to_int(board[y][x]) == 3) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 106: // j
|
||||
break;
|
||||
case 107: // k
|
||||
break;
|
||||
case 108: // l
|
||||
if (x == 7 && y == 7) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
x_direction = -7;
|
||||
y_direction = -7;
|
||||
}
|
||||
if (x < 7) {
|
||||
for (x++; x < 7; x++) {
|
||||
x_direction++;
|
||||
if (piece_color_to_int(board[y][x]) == 1 || piece_color_to_int(board[y][x]) == 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x == 7 && piece_color_to_int(board[y][x]) == 3) {
|
||||
if (y < 7) {
|
||||
y++;
|
||||
y_direction++;
|
||||
}
|
||||
if (y == 7) {
|
||||
y = 0;
|
||||
x = 0;
|
||||
x_direction = -7;
|
||||
y_direction = -7;
|
||||
for (x++; x < 7; x++) {
|
||||
x_direction++;
|
||||
if (piece_color_to_int(board[y][x]) == 1 || piece_color_to_int(board[y][x]) == 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (x == 7 && (piece_color_to_int(board[y][x]) == 1 || piece_color_to_int(board[y][x]) == 2)) {
|
||||
x = 0;
|
||||
y++;
|
||||
x_direction = -7;
|
||||
y_direction++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 10: // enter
|
||||
//a();
|
||||
break;
|
||||
case 113: // q
|
||||
return;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void controls() {
|
||||
while (1) {
|
||||
tile_selection();
|
||||
@ -202,10 +291,10 @@ void controls() {
|
||||
}
|
||||
break;
|
||||
case 106: // j
|
||||
if (x == 0 && y == 7) {
|
||||
x = 7;
|
||||
if (x == 7 && y == 7) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
x_direction = 7;
|
||||
x_direction = -7;
|
||||
y_direction = -7;
|
||||
}
|
||||
if (y < 7) {
|
||||
@ -217,7 +306,7 @@ void controls() {
|
||||
}
|
||||
}
|
||||
else if (y == 7) {
|
||||
x--;
|
||||
x++;
|
||||
y = 0;
|
||||
y_direction = -7;
|
||||
tile_selection();
|
||||
@ -230,7 +319,7 @@ void controls() {
|
||||
}
|
||||
}
|
||||
if (y == 7 && piece_color_to_int(board[y][x]) == 3) {
|
||||
x--;
|
||||
x++;
|
||||
y = 0;
|
||||
y_direction = -7;
|
||||
tile_selection();
|
||||
@ -259,7 +348,7 @@ void controls() {
|
||||
}
|
||||
}
|
||||
else if (y == 0) {
|
||||
x
|
||||
x--;
|
||||
y = 7;
|
||||
y_direction = 7;
|
||||
tile_selection();
|
||||
@ -272,6 +361,7 @@ void controls() {
|
||||
}
|
||||
}
|
||||
if (y == 0 && piece_color_to_int(board[y][x]) == 3) {
|
||||
x--;
|
||||
y = 7;
|
||||
y_direction = 7;
|
||||
tile_selection();
|
||||
@ -285,6 +375,12 @@ void controls() {
|
||||
}
|
||||
break;
|
||||
case 108: // l
|
||||
if (x == 7 && y == 7) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
x_direction = -7;
|
||||
y_direction = -7;
|
||||
}
|
||||
if (x < 7) {
|
||||
for (x++; x < 7; x++) {
|
||||
x_direction++;
|
||||
@ -294,6 +390,7 @@ void controls() {
|
||||
}
|
||||
}
|
||||
else if (x == 7) {
|
||||
y++;
|
||||
x = 0;
|
||||
x_direction = -7;
|
||||
tile_selection();
|
||||
@ -306,6 +403,7 @@ void controls() {
|
||||
}
|
||||
}
|
||||
if (x == 7 && piece_color_to_int(board[y][x]) == 3) {
|
||||
y++;
|
||||
x = 0;
|
||||
x_direction = -7;
|
||||
tile_selection();
|
||||
@ -319,7 +417,7 @@ void controls() {
|
||||
}
|
||||
break;
|
||||
case 10: // enter
|
||||
a();
|
||||
//a();
|
||||
break;
|
||||
case 113: // q
|
||||
return;
|
||||
@ -327,6 +425,7 @@ void controls() {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
int main() {
|
||||
struct termios t_old, t_new;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user