Implement quit function in main menu

Will need to revise this in the future
scene_man
En Yi 2023-08-18 23:10:48 +08:00
parent 209f09e307
commit 42e5caf695
2 changed files with 19 additions and 11 deletions

5
main.c
View File

@ -99,6 +99,11 @@ int main(void)
{ {
sc_queue_clear(&key_buffer); sc_queue_clear(&key_buffer);
} }
if (curr_scene->state == SCENE_ENDED && engine.curr_scene == 0)
{
break;
}
} }
free_sandbox_scene(&sandbox_scene); free_sandbox_scene(&sandbox_scene);
free_game_scene(&level_scene); free_game_scene(&level_scene);

View File

@ -18,17 +18,20 @@ static void menu_scene_render_func(Scene_t* scene)
static void exec_component_function(Scene_t* scene, int sel) static void exec_component_function(Scene_t* scene, int sel)
{ {
switch(sel) switch(sel)
{ {
case 0: case 0:
change_scene(scene->engine, 1); change_scene(scene->engine, 1);
break; break;
case 1: case 1:
change_scene(scene->engine, 2); change_scene(scene->engine, 2);
break; break;
default: case 3:
break; scene->state = SCENE_ENDED;
} break;
default:
break;
}
} }
static void menu_do_action(Scene_t* scene, ActionType_t action, bool pressed) static void menu_do_action(Scene_t* scene, ActionType_t action, bool pressed)