sdl_runtime_compiler git · main
SDL3 game for running and compiling code at runtime
C++ 72.3% C 26.2%git clone https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler/archive/sdl_runtime_compiler.tar.gzCleanup
src/assets/sandbox.c.last_ok | 5 ++-- src/states/game_state.cpp | 67 ++++++++++++++++++++++++++------------------ src/states/game_state.hpp | 3 ++ 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/assets/sandbox.c.last_ok b/src/assets/sandbox.c.last_ok index 37f4703..f7bff9c 100644 --- a/src/assets/sandbox.c.last_ok +++ b/src/assets/sandbox.c.last_ok @@ -21,8 +21,7 @@ int game_build ( ModObject * out , int max ) { ( void ) max ; o = out ; n = 0 ; box ( 0 , - 16 , 5 , 1 , 1 , 1 ) ; -box(2,-15,4,2,2,2); -text ( 0 , - 15 , 5 , "hi" ) ; -box ( 6 , - 15 , 10 , 1 , 1 , 5 ) ; +text ( 0 , - 15 , 5 , "FUCK" ) ; +box ( 7 , - 16 , 5 , 4 , 2 , 1 ) ; return n ; } diff --git a/src/states/game_state.cpp b/src/states/game_state.cpp index 8a500ef..9cbbb37 100644 --- a/src/states/game_state.cpp +++ b/src/states/game_state.cpp @@ -384,6 +384,32 @@ GameState::on_NumberAdjust(int delta) } +void +GameState::on_TextStart(FrameInput& input) +{ + input.text_mode = true; + input.text_buffer.clear(); + typing_words.clear(); + typing_last.clear(); +} +void +GameState::on_TextCommit(FrameInput& input) +{ + typing_words.clear(); + typing_last.clear(); + input.text_mode = false; + input.text_buffer.clear(); +} +void +GameState::on_TextCancel(FrameInput& input) +{ + typing_ClearPreview(); + typing_last.clear(); + input.text_mode = false; + input.text_buffer.clear(); +} + + void GameState::step_Spawn(const std::vector<std::string>& tokens) { @@ -499,34 +525,19 @@ GameState::update(double dt) { FP_ZONE("update.input_dispatch"); for (InputCommand cmd : input.commands) { switch (cmd) { - case InputCommand::Jump: on_Jump(); break; - case InputCommand::Click: on_Click(); break; - case InputCommand::Drop: on_DropLast(); break; - case InputCommand::ShootAll: on_ShootAll(); break; - case InputCommand::Compile: on_Compile(); break; - case InputCommand::DebugPrint: on_DebugPrint(); break; - case InputCommand::FreelookStart: on_FreelookStart(); break; - case InputCommand::FreelookEnd: on_FreelookEnd(); break; - case InputCommand::NumberInc: on_NumberAdjust(+1); break; - case InputCommand::NumberDec: on_NumberAdjust(-1); break; - case InputCommand::TextStart: - input.text_mode = true; - input.text_buffer.clear(); - typing_words.clear(); - typing_last.clear(); - break; - case InputCommand::TextCommit: - typing_words.clear(); - typing_last.clear(); - input.text_mode = false; - input.text_buffer.clear(); - break; - case InputCommand::TextCancel: - typing_ClearPreview(); - typing_last.clear(); - input.text_mode = false; - input.text_buffer.clear(); - break; + case InputCommand::Jump: on_Jump(); break; + case InputCommand::Click: on_Click(); break; + case InputCommand::Drop: on_DropLast(); break; + case InputCommand::ShootAll: on_ShootAll(); break; + case InputCommand::Compile: on_Compile(); break; + case InputCommand::DebugPrint: on_DebugPrint(); break; + case InputCommand::FreelookStart: on_FreelookStart(); break; + case InputCommand::FreelookEnd: on_FreelookEnd(); break; + case InputCommand::NumberInc: on_NumberAdjust(+1); break; + case InputCommand::NumberDec: on_NumberAdjust(-1); break; + case InputCommand::TextStart: on_TextStart (input); break; + case InputCommand::TextCommit: on_TextCommit(input); break; + case InputCommand::TextCancel: on_TextCancel(input); break; } } if (input.text_mode) { diff --git a/src/states/game_state.hpp b/src/states/game_state.hpp index e954df0..a88f9cf 100644 --- a/src/states/game_state.hpp +++ b/src/states/game_state.hpp @@ -119,6 +119,9 @@ class GameState : public IState void on_FreelookEnd(); void on_Compile(); void on_NumberAdjust(int dt); + void on_TextStart (FrameInput&); + void on_TextCommit(FrameInput&); + void on_TextCancel(FrameInput&); void scene_Setup(const Scene& scene); void scene_Teardown();