Compare commits

..

No commits in common. "d07587c654e84979455010ad01dfccb18db67ba3" and "36b962ece19bae4e42f2e2dcd2988cafb4b53efc" have entirely different histories.

19
main.c
View File

@ -2,7 +2,6 @@
#include <termios.h>
#include <unistd.h>
#include <locale.h>
#include <stdlib.h>
#define FG_DEFAULT_BG_WHITE "\x1b[30;48;5;255m"
#define FG_DEFAULT_BG_136 "\x1b[30;48;5;136m"
@ -112,7 +111,7 @@ int print_tab() {
return 0;
}
void piece_selection() {
int piece_selection() {
if (y % 2 == 1) {
if (x % 2 == 0) {
@ -130,10 +129,12 @@ void piece_selection() {
printf(FG_DEFAULT_BG_136"\x1b[%d;%dH%s", y - y_direction + 1 , (x - x_direction) * 2 + 1, piece_to_str(board[y - y_direction][x - x_direction]));
}
}
printf("\x1b[%d;%dH\x1b[39;106m%s", y + 1 , x * 2 + 1, piece_to_str(board[y][x]));
printf("\x1b[%d;%dH\x1b[39;49ma", y + 1 , x * 2 + 1);
}
void controls() {
int controls() {
piece_selection();
@ -158,7 +159,7 @@ void controls() {
}
break;
case 106: // j
if (y < 7 && (piece_color[y + 1][x] == 1 || piece_color[y + 1][x] == 2)) {
if (y < 7 && (piece_color[y][x - 1] == 1 || piece_color[y][x - 1] == 2)) {
y++;
y_direction++;
piece_selection();
@ -170,7 +171,7 @@ void controls() {
}
break;
case 107: // k
if (y > 6 && (piece_color[y - 1][x] == 1 || piece_color[y - 1][x] == 2)) {
if (y > 6 && (piece_color[y][x - 1] == 1 || piece_color[y][x - 1] == 2)) {
y--;
y_direction = -1;
piece_selection();
@ -182,7 +183,7 @@ void controls() {
}
break;
case 108: // l
if (x < 7 && (piece_color[y][x + 1] == 1 || piece_color[y][x + 1] == 2)) {
if (x < 7 && (piece_color[y][x - 1] == 1 || piece_color[y][x - 1] == 2)) {
x++;
x_direction++;
piece_selection();
@ -193,12 +194,10 @@ void controls() {
piece_selection();
}
break;
case 113:
printf("\x1b[?25h");
exit(0);
default: break;
}
}
return 0;
}
int main() {