IT WORKS NOW

This commit is contained in:
Rorikstr | Rust Dev 2025-09-29 19:23:14 +03:00
parent f5b65a390b
commit 0f2d03526e
14 changed files with 19477 additions and 31 deletions

View file

@ -1,7 +1,10 @@
#include "01_automato.h"
#include <stdlib.h>
#include "../../logging.h"
GameState_t* get_game_state(void) {
LOG_FUNCTION_START("get_game_state", "");
static GameState_t state = {0};
static int initialized = 0;
@ -21,13 +24,31 @@ GameState_t* get_game_state(void) {
state.info->next[i] = malloc(4 * sizeof(int));
}
// Инициализируем начальные значения
state.info->speed = 1;
state.info->score = 0;
state.info->level = 1;
state.info->pause = 0;
// Инициализируем следующую фигуру
state.next.sprite = rand() % FIGURE_COUNT;
state.next.rotation = 0;
const int (*shape)[4] = get_figure_shape(state.next.sprite, 0);
for (int i = 0; i < 4; ++i)
for (int j = 0; j < 4; ++j)
state.next.mtrx[i][j] = shape[i][j];
state.state = GameOver;
initialized = 1;
}
LOG_FUNCTION_END("get_game_state", "state=%d", state.state);
return &state;
}
void terminate_and_free() {
LOG_FUNCTION_START("terminate_and_free", "");
GameState_t* state = get_game_state();
if (state->info) {
@ -56,4 +77,6 @@ void terminate_and_free() {
free(state->info);
state->info = NULL;
}
LOG_FUNCTION_END("terminate_and_free", "");
}