Nimbin[12]?SDL & Graphics / sdl_runtime_compiler / commits / 2cc5329

sdl_runtime_compiler git · main

SDL3 game for running and compiling code at runtime

sdl3 c++ compiler dlopen cmake · first commit 2026-04-19 · last commit 2026-07-03 (3 months ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/sdl-runtime-compiler

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.gz

Update tutorial a bit

Christian Immanuel · 2026-06-03 21:39 · 2cc532938fc3f89ff92c74dec40e497dd6df0286

 src/levels/level/tutorial.cpp | 109 ++++++++++++++++++++----------------------
 src/levels/scene.hpp          |   8 ++--
 2 files changed, 57 insertions(+), 60 deletions(-)

diff --git a/src/levels/level/tutorial.cpp b/src/levels/level/tutorial.cpp
index 1237a03..e6972df 100644
--- a/src/levels/level/tutorial.cpp
+++ b/src/levels/level/tutorial.cpp
@@ -10,46 +10,16 @@ Level::build_Tutorial()
         .desc = "Learn the controls and the code-building loop.",
         .steps = {
 
-            {
-                .hint    = "Walk to the green plate",
-                .details = R"(Welcome.
-
-Use W, A, S, D to walk.
-Move the mouse to turn.
-
-A green plate sits on the floor a short walk away.
-Step onto it to continue.)",
-                .grants = {
-                    Level::TokenGrant::give("#include <stdio.h>"   ),
-                    Level::TokenGrant::give("int main(void) {"     ),
-                    Level::TokenGrant::give("int in_;"             ),
-                    Level::TokenGrant::give("scanf(\"%d\", &in_);" ),
-                    Level::TokenGrant::give("printf(\"%d\\n\", in_);"),
-                    Level::TokenGrant::give("return 0; }"          ),
-                },
-                .scene   = Scene{
-                    .words  = {},
-                    .plates = {
-                        { .pos = { 0.0, static_cast<double>(-ConfigGame::world_box_scale), 6.0 }, .tag = "" },
-                    },
-                    .platforms = {},
-                    .ai_seeds  = {},
-                },
-                .reset_carry  = true,
-                .goal         = ReachPlate{ "" },
-                .max_ai_words = 0,
-            },
-
             {
                 .hint    = "Jump up the steps to the plate",
                 .details = R"(Press SPACE to jump.
 
-Ahead is a short staircase of blocks.
-Hop up them, one at a time, and stand on the
-plate at the top.
+Use [wasd] to walk.
+Move the mouse to turn.
+
+Jump with SPACE.
 
-From now on, plates that advance the tutorial sit
-up high — you'll need this jump to reach them.)",
+Jump on the plate on top of the platform. )",
                 .grants  = {},
                 .scene   = Scene{
                     .words = {},
@@ -73,14 +43,11 @@ up high — you'll need this jump to reach them.)",
                 .details = R"(Move the mouse to look around.
 
 Four walls surround you:
-  - Editor:   where you build code (the pults face it)
+  - Editor:   where you build code (the scroll and clear pults face it)
   - Compiler: shows compile messages
   - Program:  shows your program's output
   - Info:     this wall, with hints
-
-Tip: hold C to free-look without turning your body.
-
-When you've seen them all, jump onto the plate.)",
+)",
                 .grants  = {},
                 .scene   = Scene{
                     .words  = {},
@@ -98,11 +65,14 @@ When you've seen them all, jump onto the plate.)",
             },
 
             {
-                .hint    = "Walk into the floating word and press E",
+                .hint    = "Walk into the floating word and press 'e'",
                 .details = R"(Words float in the air.
 
-Walk up to "hello" and press E to pick it up.
-Picked words trail in front of you as you move.)",
+Walk up to "hello" and press 'e' to pick it up.
+Picked words trail in front of you as you move.
+
+> hold SHIFT to free-look without turning your body.")
+)",
                 .grants  = {},
                 .scene   = Scene{
                     .words = {
@@ -118,17 +88,17 @@ Picked words trail in front of you as you move.)",
             },
 
             {
-                .hint    = "Pick up all three words",
+                .hint    = "Keep 'e' pressed and pick up all words.",
                 .details = R"(You can carry several words at once.
 
-Collect "press", "any" and "key" with E.
+Collect "press", "any" and "key" with 'e'.
 They queue up in the order you grab them.)",
                 .grants  = {},
                 .scene   = Scene{
                     .words = {
-                        { .text = "press", .pos = {  5.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
-                        { .text = "any",   .pos = {  0.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
-                        { .text = "key",   .pos = { -5.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
+                        { .text = "keep",    .pos = {  5.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
+                        { .text = "e",       .pos = {  0.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
+                        { .text = "pressed", .pos = { -5.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
                     },
                     .plates    = {},
                     .platforms = {},
@@ -136,16 +106,16 @@ They queue up in the order you grab them.)",
                 },
                 .reset_carry  = false,
                 .goal = AllOf{{
-                    CollectWord{ "press" },
-                    CollectWord{ "any"   },
-                    CollectWord{ "key"   },
+                    CollectWord{ "keep" },
+                    CollectWord{ "e"    },
+                    CollectWord{ "pressed" },
                 }},
                 .max_ai_words = 0,
             },
 
             {
-                .hint    = "Press Q to drop the last word",
-                .details = R"(Q drops the most recently picked word.
+                .hint    = "Press 'q' to drop a word",
+                .details = R"('q' drops the most recently picked word.
 
 The dropped word falls to the floor — handy for
 putting back something you grabbed by mistake.)",
@@ -157,14 +127,37 @@ putting back something you grabbed by mistake.)",
             },
 
             {
-                .hint    = "LEFT CLICK to throw a word",
+                .hint    = "LEFT CLICK to throw a word (you can keep it pressed)",
                 .details = R"(Left click throws the word at the front of your line.
 
 Aim with the crosshair and throw — any direction is fine.
 
 Carrying several? Tap F to throw the WHOLE line at once.)",
                 .grants  = {},
-                .scene   = {},
+                .scene   = {
+                    .words = {
+                        { .text = "keep",    .pos = {  5.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
+                        { .text = "left",    .pos = {  3.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
+                        { .text = "click",   .pos = {  0.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
+                        { .text = "pressed", .pos = {  2.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
+                    },
+                },
+                .reset_carry  = false,
+                .goal         = ShotWord{},
+                .max_ai_words = 0,
+            },
+            {
+                .hint    = "Press 'f' to flush all carried words",
+                .details = R"(Bla blub
+...)",
+                .grants  = {},
+                .scene   = {
+                    .words = {
+                        { .text = "f",    .pos = {  1.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
+                        { .text = "for",  .pos = {  2.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -2.0 } },
+                        { .text = "flush",.pos = {  0.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), -3.0 } },
+                    },
+                },
                 .reset_carry  = false,
                 .goal         = ShotWord{},
                 .max_ai_words = 0,
@@ -182,6 +175,10 @@ reaches you.)",
                 .scene   = Scene{
                     .words = {
                         { .text = "ammo", .pos = { 6.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), 6.0 } },
+                        { .text = "ammo", .pos = { 3.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), 2.0 } },
+                        { .text = "ammo", .pos = { 6.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), 3.0 } },
+                        { .text = "ammo", .pos = { 4.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), 6.0 } },
+                        { .text = "ammo", .pos = { 6.0, static_cast<double>(-ConfigGame::world_box_scale + 1.5f), 1.0 } },
                     },
                     .plates    = {},
                     .platforms = {},
@@ -216,7 +213,7 @@ Build exactly:
   int main(void) { return 0; }
 
 Then walk to the Compile pult (labelled BUILD) and
-press it.)",
+press it (or press 'c' to compile).)",
                 .grants = {
                     Level::TokenGrant::give("int"),
                     Level::TokenGrant::give("main"),
diff --git a/src/levels/scene.hpp b/src/levels/scene.hpp
index 2ed69d0..5794eca 100644
--- a/src/levels/scene.hpp
+++ b/src/levels/scene.hpp
@@ -50,8 +50,8 @@ struct PlacedAi {
 // All spatial content for a single step. Spawned on step entry, removed
 // on step advance (or reset).
 struct Scene {
-    DynArray<PlacedWord>     words;
-    DynArray<PlacedPlate>    plates;
-    DynArray<PlacedPlatform> platforms;
-    DynArray<PlacedAi>       ai_seeds;
+    DynArray<PlacedWord>     words    {};
+    DynArray<PlacedPlate>    plates   {};
+    DynArray<PlacedPlatform> platforms{};
+    DynArray<PlacedAi>       ai_seeds {};
 };