Всё фигня, давай по новой
This commit is contained in:
parent
485ac0ca40
commit
f8e1e664a7
13 changed files with 199 additions and 479 deletions
26
src/brick_game/tetris/05_spawn.c
Normal file
26
src/brick_game/tetris/05_spawn.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "01_automato.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void do_spawn(void) {
|
||||
GameState_t* state = get_game_state();
|
||||
// Присваиваем curr = next
|
||||
state->curr = state->next;
|
||||
state->curr.x = FIELD_WIDTH / 2 - 2;
|
||||
state->curr.y = 0;
|
||||
|
||||
// Генерим следующую фигуру
|
||||
state->next.type = rand() % FIGURE_COUNT;
|
||||
state->next.rotation = 0;
|
||||
const int (*shape)[4] = get_figure_shape(state->next.type, 0);
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
state->next.mtrx[i][j] = shape[i][j];
|
||||
|
||||
// Проверка на GameOver
|
||||
if (check_collision()) {
|
||||
state->state = GameOver;
|
||||
return;
|
||||
}
|
||||
|
||||
state->state = Move;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue