diff --git a/src/game.cc b/src/game.cc index 6522250..ff14e51 100644 --- a/src/game.cc +++ b/src/game.cc @@ -23,3 +23,8 @@ void Game::update() { void Game::draw() { screen_stack->draw(); } void Game::clear_screens() { screen_stack->clear_screens(); } + +void Game::clear_and_push_trunner() { + screen_stack->clear_screens(); + screen_stack->push_constructing_screen(); +} diff --git a/src/game.h b/src/game.h index 1d6c764..1a50778 100644 --- a/src/game.h +++ b/src/game.h @@ -23,6 +23,7 @@ class Game { void draw(); void clear_screens(); + void clear_and_push_trunner(); private: ScreenStack::Ptr screen_stack; diff --git a/src/main.cc b/src/main.cc index a0287e2..9548455 100644 --- a/src/main.cc +++ b/src/main.cc @@ -16,7 +16,7 @@ #ifdef __EMSCRIPTEN__ -extern Game *global_game_ptr = nullptr; +extern Game *global_game_ptr; extern "C" { @@ -37,6 +37,14 @@ int EMSCRIPTEN_KEEPALIVE clear_all_screens() { return 1; } +int EMSCRIPTEN_KEEPALIVE clear_and_push_trunner() { + if (global_game_ptr) { + global_game_ptr->clear_and_push_trunner(); + return 0; + } + return 1; +} + } // extern "C" #endif diff --git a/wasm_build/custom_shell.html b/wasm_build/custom_shell.html index 2bf70b1..7166eb9 100644 --- a/wasm_build/custom_shell.html +++ b/wasm_build/custom_shell.html @@ -60,7 +60,10 @@ console.log("onerror: " + event); }; function demo0_clear_all_screens() { - Module.ccall('clear_all_screens', 'number', [], []); + return Module.ccall('clear_all_screens', 'number', [], []); + }; + function demo0_clear_and_push_trunner() { + return Module.ccall('clear_and_push_trunner', 'number', [], []); }; {{{ SCRIPT }}}