start is working

This commit is contained in:
Rorikstr | Rust Dev 2025-09-28 19:38:54 +03:00
parent 3c7e55dd6f
commit 485ac0ca40
2 changed files with 8 additions and 9 deletions

View file

@ -46,11 +46,12 @@ void init_game() {
state->next_figure.rotation = 0;
state->score = 0;
state->high_score = 0;
state->level = 1;
state->drop_time = time(NULL) * 1000;
state->game_over = false;
state->paused = false;
state->state = FSM_Start; // Начинаем в состоянии Start
state->state = FSM_Start; // Начинаем в состоянии FSM_Start
}
void place_figure() {
@ -92,7 +93,7 @@ void place_figure() {
}
void clear_completed_lines() {
GameStateData* state = get_game_state();
GameStateData* state = get_instance();
int lines_cleared = 0;
int write_row = FIELD_HEIGHT - 1;
@ -177,7 +178,7 @@ bool check_collision() {
}
void fsm_transition() {
GameStateData* state = get_game_state();
GameStateData* state = get_instance();
switch (state->state) {
case FSM_Start:
@ -215,8 +216,6 @@ void fsm_transition() {
case FSM_Attaching:
place_figure();
// После place_figure проверяем, не произошел ли Game Over
// В place_figure уже устанавливается FSM_Spawn, но нужно проверить столкновение
break;
case FSM_GameOver:

View file

@ -75,7 +75,7 @@ void userInput(UserAction_t action, bool hold) {
int saved_high_score = state->high_score;
init_game();
state->high_score = saved_high_score;
// Не меняем состояние, пусть остается в Start до следующего нажатия
// Не меняем состояние, пусть остается в FSM_Start до следующего нажатия
} else if (state->state == FSM_Start) {
// Начинаем игру из состояния Start
state->state = FSM_Spawn;
@ -84,7 +84,7 @@ void userInput(UserAction_t action, bool hold) {
state->paused = !state->paused;
}
break;
case Pause:
state->paused = !state->paused;
break;
@ -194,8 +194,8 @@ GameInfo_t updateCurrentState() {
// Обновляем next
const int (*next_shape)[4];
if (state->state == FSM_GameOver || state->state == FSM_Start) {
// При game_over или в начальном состоянии показываем пустую фигуру
if (state->state == FSM_GameOver) {
// При game_over показываем пустую фигуру
next_shape = empty_fig();
} else {
next_shape = get_figure_shape(state->next_figure.type, state->next_figure.rotation);