clang-format
This commit is contained in:
parent
ace9659ef5
commit
9e712ae326
12 changed files with 720 additions and 769 deletions
|
|
@ -35,7 +35,7 @@ TEST_TARGET = $(BUILDDIR)/test.out
|
||||||
PREFIX ?= $(HOME)/.local
|
PREFIX ?= $(HOME)/.local
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
|
|
||||||
all: $(TARGET)
|
all: dvi dist install gcov_report run
|
||||||
|
|
||||||
run: clean $(TARGET)
|
run: clean $(TARGET)
|
||||||
./$(TARGET)
|
./$(TARGET)
|
||||||
|
|
@ -100,14 +100,14 @@ dist: clean
|
||||||
tar -czf tetris.tar.gz Makefile $(TETRISDIR) $(CLIDIR) $(TESTDIR) README.md doc.md
|
tar -czf tetris.tar.gz Makefile $(TETRISDIR) $(CLIDIR) $(TESTDIR) README.md doc.md
|
||||||
|
|
||||||
style:
|
style:
|
||||||
@if [ -f .clang-format ]; then \
|
@if [ -f ../materials/linters/.clang-format ]; then \
|
||||||
clang-format -n $(TETRIS_SRC) $(CLI_SRC); \
|
clang-format -n $(TETRIS_SRC) $(CLI_SRC); \
|
||||||
else \
|
else \
|
||||||
echo ".clang-format not found"; \
|
echo ".clang-format not found"; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
format:
|
format:
|
||||||
@if [ -f .clang-format ]; then \
|
@if [ -f ../materials/linters/.clang-format ]; then \
|
||||||
clang-format -i $(TETRIS_SRC) $(CLI_SRC); \
|
clang-format -i $(TETRIS_SRC) $(CLI_SRC); \
|
||||||
else \
|
else \
|
||||||
echo ".clang-format not found"; \
|
echo ".clang-format not found"; \
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,16 @@ void userInput(UserAction_t action, bool hold) {
|
||||||
|
|
||||||
// Проверка паузы
|
// Проверка паузы
|
||||||
if (state->info->pause) {
|
if (state->info->pause) {
|
||||||
if (action == Left || action == Right || action == Down ||
|
if (action == Left || action == Right || action == Down || action == Up ||
|
||||||
action == Up || action == Action || action == Start) {
|
action == Action || action == Start) {
|
||||||
should_process = 0;
|
should_process = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Блокируем движения во время Attaching (до завершения задержки)
|
// Блокируем движения во время Attaching (до завершения задержки)
|
||||||
if (state->state == Attaching && !state->attach_completed) {
|
if (state->state == Attaching && !state->attach_completed) {
|
||||||
if (action == Left || action == Right || action == Down ||
|
if (action == Left || action == Right || action == Down || action == Up ||
|
||||||
action == Up || action == Action) {
|
action == Action) {
|
||||||
should_process = 0;
|
should_process = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -67,10 +67,12 @@ void userInput(UserAction_t action, bool hold) {
|
||||||
if (!state->info->pause) {
|
if (!state->info->pause) {
|
||||||
state->pause_start_time = get_current_time_ms();
|
state->pause_start_time = get_current_time_ms();
|
||||||
} else {
|
} else {
|
||||||
long long pause_duration = get_current_time_ms() - state->pause_start_time;
|
long long pause_duration =
|
||||||
|
get_current_time_ms() - state->pause_start_time;
|
||||||
state->last_move_time += pause_duration;
|
state->last_move_time += pause_duration;
|
||||||
// Корректируем attach_start_time если мы в Attaching
|
// Корректируем attach_start_time если мы в Attaching
|
||||||
state->attach_start_time += (state->state == Attaching) * pause_duration;
|
state->attach_start_time +=
|
||||||
|
(state->state == Attaching) * pause_duration;
|
||||||
}
|
}
|
||||||
state->info->pause = !state->info->pause;
|
state->info->pause = !state->info->pause;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,10 @@ int get_milliseconds_to_wait(void) {
|
||||||
if (state->moving_type == ToDown) {
|
if (state->moving_type == ToDown) {
|
||||||
result = INSTANT_DROP_DELAY_MS;
|
result = INSTANT_DROP_DELAY_MS;
|
||||||
} else {
|
} else {
|
||||||
int base_delay = BASE_FALL_DELAY_MS - (state->info->speed * SPEED_MULTIPLIER_MS);
|
int base_delay =
|
||||||
result = (base_delay > SPEED_MULTIPLIER_MS) ? base_delay : SPEED_MULTIPLIER_MS;
|
BASE_FALL_DELAY_MS - (state->info->speed * SPEED_MULTIPLIER_MS);
|
||||||
|
result =
|
||||||
|
(base_delay > SPEED_MULTIPLIER_MS) ? base_delay : SPEED_MULTIPLIER_MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ void handle_move_direction(Moving_t direction) {
|
||||||
void handle_rotate(void) {
|
void handle_rotate(void) {
|
||||||
GameState_t *state = get_game_state();
|
GameState_t *state = get_game_state();
|
||||||
state->curr.rotation = (state->curr.rotation + 1) % 4;
|
state->curr.rotation = (state->curr.rotation + 1) % 4;
|
||||||
const int (*shape)[4] = get_figure_shape(state->curr.sprite, state->curr.rotation);
|
const int(*shape)[4] =
|
||||||
|
get_figure_shape(state->curr.sprite, state->curr.rotation);
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
for (int j = 0; j < 4; ++j)
|
for (int j = 0; j < 4; ++j)
|
||||||
state->curr.mtrx[i][j] = shape[i][j];
|
state->curr.mtrx[i][j] = shape[i][j];
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,8 @@ void clear_lines() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines_cleared > 0) {
|
if (lines_cleared > 0) {
|
||||||
int points[] = {0, POINTS_ONE_LINE, POINTS_TWO_LINES, POINTS_THREE_LINES, POINTS_FOUR_LINES};
|
int points[] = {0, POINTS_ONE_LINE, POINTS_TWO_LINES, POINTS_THREE_LINES,
|
||||||
|
POINTS_FOUR_LINES};
|
||||||
state->info->score += points[lines_cleared];
|
state->info->score += points[lines_cleared];
|
||||||
|
|
||||||
if (state->info->score > state->info->high_score) {
|
if (state->info->score > state->info->high_score) {
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,18 @@ const int (*get_figure_shape(Sprite_t sprite, int rotation))[4] {
|
||||||
switch (sprite) {
|
switch (sprite) {
|
||||||
case I:
|
case I:
|
||||||
switch (rotation % 4) {
|
switch (rotation % 4) {
|
||||||
case 0: result = i_fig_up(); break;
|
case 0:
|
||||||
case 1: result = i_fig_right(); break;
|
result = i_fig_up();
|
||||||
case 2: result = i_fig_down(); break;
|
break;
|
||||||
case 3: result = i_fig_left(); break;
|
case 1:
|
||||||
|
result = i_fig_right();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
result = i_fig_down();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
result = i_fig_left();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case O:
|
case O:
|
||||||
|
|
@ -16,45 +24,86 @@ const int (*get_figure_shape(Sprite_t sprite, int rotation))[4] {
|
||||||
break;
|
break;
|
||||||
case T:
|
case T:
|
||||||
switch (rotation % 4) {
|
switch (rotation % 4) {
|
||||||
case 0: result = t_fig_up(); break;
|
case 0:
|
||||||
case 1: result = t_fig_right(); break;
|
result = t_fig_up();
|
||||||
case 2: result = t_fig_down(); break;
|
break;
|
||||||
case 3: result = t_fig_left(); break;
|
case 1:
|
||||||
|
result = t_fig_right();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
result = t_fig_down();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
result = t_fig_left();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case L:
|
case L:
|
||||||
switch (rotation % 4) {
|
switch (rotation % 4) {
|
||||||
case 0: result = l_fig_up(); break;
|
case 0:
|
||||||
case 1: result = l_fig_right(); break;
|
result = l_fig_up();
|
||||||
case 2: result = l_fig_down(); break;
|
break;
|
||||||
case 3: result = l_fig_left(); break;
|
case 1:
|
||||||
|
result = l_fig_right();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
result = l_fig_down();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
result = l_fig_left();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case J:
|
case J:
|
||||||
switch (rotation % 4) {
|
switch (rotation % 4) {
|
||||||
case 0: result = j_fig_up(); break;
|
case 0:
|
||||||
case 1: result = j_fig_right(); break;
|
result = j_fig_up();
|
||||||
case 2: result = j_fig_down(); break;
|
break;
|
||||||
case 3: result = j_fig_left(); break;
|
case 1:
|
||||||
|
result = j_fig_right();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
result = j_fig_down();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
result = j_fig_left();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case S:
|
case S:
|
||||||
switch (rotation % 4) {
|
switch (rotation % 4) {
|
||||||
case 0: result = s_fig_up(); break;
|
case 0:
|
||||||
case 1: result = s_fig_right(); break;
|
result = s_fig_up();
|
||||||
case 2: result = s_fig_down(); break;
|
break;
|
||||||
case 3: result = s_fig_left(); break;
|
case 1:
|
||||||
|
result = s_fig_right();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
result = s_fig_down();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
result = s_fig_left();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Z:
|
case Z:
|
||||||
switch (rotation % 4) {
|
switch (rotation % 4) {
|
||||||
case 0: result = z_fig_up(); break;
|
case 0:
|
||||||
case 1: result = z_fig_right(); break;
|
result = z_fig_up();
|
||||||
case 2: result = z_fig_down(); break;
|
break;
|
||||||
case 3: result = z_fig_left(); break;
|
case 1:
|
||||||
|
result = z_fig_right();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
result = z_fig_down();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
result = z_fig_left();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: result = NULL;
|
default:
|
||||||
|
result = NULL;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -62,266 +111,162 @@ const int (*get_figure_shape(Sprite_t sprite, int rotation))[4] {
|
||||||
// I
|
// I
|
||||||
const int (*i_fig_up())[4] {
|
const int (*i_fig_up())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
{1, 1, 1, 1},
|
|
||||||
{0, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*i_fig_right())[4] {
|
const int (*i_fig_right())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 0, 1, 0},
|
{0, 0, 1, 0}, {0, 0, 1, 0}, {0, 0, 1, 0}, {0, 0, 1, 0}};
|
||||||
{0, 0, 1, 0},
|
|
||||||
{0, 0, 1, 0},
|
|
||||||
{0, 0, 1, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*i_fig_down())[4] {
|
const int (*i_fig_down())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}};
|
||||||
{0, 0, 0, 0},
|
|
||||||
{1, 1, 1, 1},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*i_fig_left())[4] {
|
const int (*i_fig_left())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 1, 0, 0},
|
{0, 1, 0, 0}, {0, 1, 0, 0}, {0, 1, 0, 0}, {0, 1, 0, 0}};
|
||||||
{0, 1, 0, 0},
|
|
||||||
{0, 1, 0, 0},
|
|
||||||
{0, 1, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
// O
|
// O
|
||||||
const int (*o_fig())[4] {
|
const int (*o_fig())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 1, 1, 0},
|
{0, 1, 1, 0}, {0, 1, 1, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
{0, 1, 1, 0},
|
|
||||||
{0, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
// T
|
// T
|
||||||
const int (*t_fig_up())[4] {
|
const int (*t_fig_up())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 1, 0, 0},
|
{0, 1, 0, 0}, {1, 1, 1, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
{1, 1, 1, 0},
|
|
||||||
{0, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*t_fig_right())[4] {
|
const int (*t_fig_right())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 1, 0, 0},
|
{0, 1, 0, 0}, {0, 1, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}};
|
||||||
{0, 1, 1, 0},
|
|
||||||
{0, 1, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*t_fig_down())[4] {
|
const int (*t_fig_down())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0}, {1, 1, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}};
|
||||||
{1, 1, 1, 0},
|
|
||||||
{0, 1, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*t_fig_left())[4] {
|
const int (*t_fig_left())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 1, 0, 0},
|
{0, 1, 0, 0}, {1, 1, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}};
|
||||||
{1, 1, 0, 0},
|
|
||||||
{0, 1, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
// L
|
// L
|
||||||
const int (*l_fig_up())[4] {
|
const int (*l_fig_up())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 0, 1, 0},
|
{0, 0, 1, 0}, {1, 1, 1, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
{1, 1, 1, 0},
|
|
||||||
{0, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*l_fig_right())[4] {
|
const int (*l_fig_right())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{1, 0, 0, 0},
|
{1, 0, 0, 0}, {1, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}};
|
||||||
{1, 0, 0, 0},
|
|
||||||
{1, 1, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*l_fig_down())[4] {
|
const int (*l_fig_down())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0}, {1, 1, 1, 0}, {1, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
{1, 1, 1, 0},
|
|
||||||
{1, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*l_fig_left())[4] {
|
const int (*l_fig_left())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{1, 1, 0, 0},
|
{1, 1, 0, 0}, {0, 1, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}};
|
||||||
{0, 1, 0, 0},
|
|
||||||
{0, 1, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
// J
|
// J
|
||||||
const int (*j_fig_up())[4] {
|
const int (*j_fig_up())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{1, 0, 0, 0},
|
{1, 0, 0, 0}, {1, 1, 1, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
{1, 1, 1, 0},
|
|
||||||
{0, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*j_fig_right())[4] {
|
const int (*j_fig_right())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 1, 1, 0},
|
{0, 1, 1, 0}, {0, 1, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}};
|
||||||
{0, 1, 0, 0},
|
|
||||||
{0, 1, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*j_fig_down())[4] {
|
const int (*j_fig_down())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0}, {1, 1, 1, 0}, {0, 0, 1, 0}, {0, 0, 0, 0}};
|
||||||
{1, 1, 1, 0},
|
|
||||||
{0, 0, 1, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*j_fig_left())[4] {
|
const int (*j_fig_left())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 1, 0, 0},
|
{0, 1, 0, 0}, {0, 1, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}};
|
||||||
{0, 1, 0, 0},
|
|
||||||
{1, 1, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
// S
|
// S
|
||||||
const int (*s_fig_up())[4] {
|
const int (*s_fig_up())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 1, 1, 0},
|
{0, 1, 1, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
{1, 1, 0, 0},
|
|
||||||
{0, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*s_fig_right())[4] {
|
const int (*s_fig_right())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 1, 0, 0},
|
{0, 1, 0, 0}, {0, 1, 1, 0}, {0, 0, 1, 0}, {0, 0, 0, 0}};
|
||||||
{0, 1, 1, 0},
|
|
||||||
{0, 0, 1, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*s_fig_down())[4] {
|
const int (*s_fig_down())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 1, 1, 0},
|
{0, 1, 1, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
{1, 1, 0, 0},
|
|
||||||
{0, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*s_fig_left())[4] {
|
const int (*s_fig_left())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 1, 0, 0},
|
{0, 1, 0, 0}, {0, 1, 1, 0}, {0, 0, 1, 0}, {0, 0, 0, 0}};
|
||||||
{0, 1, 1, 0},
|
|
||||||
{0, 0, 1, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Z
|
// Z
|
||||||
const int (*z_fig_up())[4] {
|
const int (*z_fig_up())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{1, 1, 0, 0},
|
{1, 1, 0, 0}, {0, 1, 1, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
{0, 1, 1, 0},
|
|
||||||
{0, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*z_fig_right())[4] {
|
const int (*z_fig_right())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 0, 1, 0},
|
{0, 0, 1, 0}, {0, 1, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}};
|
||||||
{0, 1, 1, 0},
|
|
||||||
{0, 1, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*z_fig_down())[4] {
|
const int (*z_fig_down())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{1, 1, 0, 0},
|
{1, 1, 0, 0}, {0, 1, 1, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
{0, 1, 1, 0},
|
|
||||||
{0, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*z_fig_left())[4] {
|
const int (*z_fig_left())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 0, 1, 0},
|
{0, 0, 1, 0}, {0, 1, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}};
|
||||||
{0, 1, 1, 0},
|
|
||||||
{0, 1, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int (*empty_fig())[4] {
|
const int (*empty_fig())[4] {
|
||||||
static const int shape[4][4] = {
|
static const int shape[4][4] = {
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
|
||||||
{0, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
return (const int(*)[4])shape;
|
return (const int(*)[4])shape;
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// src/gui/cli/display.c
|
// src/gui/cli/display.c
|
||||||
#include <ncurses.h>
|
|
||||||
#include "../../brick_game/tetris/00_tetris.h"
|
#include "../../brick_game/tetris/00_tetris.h"
|
||||||
|
#include <ncurses.h>
|
||||||
|
|
||||||
void display_game(GameInfo_t game_state) {
|
void display_game(GameInfo_t game_state) {
|
||||||
clear();
|
clear();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
|
#include "../../brick_game/tetris/00_tetris.h"
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "../../brick_game/tetris/00_tetris.h"
|
#include <unistd.h>
|
||||||
|
|
||||||
void display_game(GameInfo_t game_state);
|
void display_game(GameInfo_t game_state);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue