Nimbin[12]?SDL & Graphics / sdl_runtime_compiler / commits / 4a65135

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

Success banner within world scale With Claude

Christian Immanuel · 2026-06-06 01:56 · 4a65135273e9eab13e4bd00e347e739751b4dc9f

 src/systems/celebration_system.cpp | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/systems/celebration_system.cpp b/src/systems/celebration_system.cpp
index 3dbd98f..50295b9 100644
--- a/src/systems/celebration_system.cpp
+++ b/src/systems/celebration_system.cpp
@@ -10,19 +10,28 @@ CelebrationSystem::start(const Camera& cam, double& glyph_yaw)
     _t          = 0.0;
     _next_burst = 0.0;
 
+    const double ws     = World::get_BoxScale<double>();
+    const double floor  = World::get_FloorY<double>();
+    const double margin = 1.0;
+
     Vec3 banner_pos {
         cam.pos.x + cam.fwd.x * 10.0,
         cam.pos.y + cam.fwd.y * 10.0,
         cam.pos.z + cam.fwd.z * 10.0,
     };
 
-    if (banner_pos.y < World::get_FloorY<double>()+1.0) 
-        banner_pos.y = World::get_FloorY<double>()+1.0;
+    auto clamp = [](double v, double lo, double hi) {
+        return v < lo ? lo : (v > hi ? hi : v);
+    };
+
+    banner_pos.x = clamp(banner_pos.x, -ws + margin, ws - margin);
+    banner_pos.z = clamp(banner_pos.z, -ws + margin, ws - margin);
+    banner_pos.y = clamp(banner_pos.y, floor + 1.0,  ws - margin);
 
     _banner = make_Text3d("Success",
-                         Text3d::depth_floor * 2.0f,
-                         0.012f, banner_pos,
-                         ConfigColor::white);
+                          Text3d::depth_floor * 2.0f,
+                          0.012f, banner_pos,
+                          ConfigColor::white);
     _banner->yaw       = static_cast<float>(glyph_yaw);
     _banner->body.mode = PhysicsMode::Static;
 }
@@ -35,16 +44,11 @@ CelebrationSystem::tick(double dt, ParticleSystem& particle_sys)
 
     _t += dt;
 
-    // Slow banner spin
     if (_banner)
         _banner->yaw += static_cast<float>(dt * 0.6);
 
-    // Fireworks bursts on a schedule. We aim for ~7 bursts across the
-    // duration, with slight jitter to avoid mechanical pacing.
     if (_t >= _next_burst &&
         _t <  _duration - 0.3) {
-        // Random position across the play area, biased to upper half so
-        // bursts read as airborne fireworks not floor_sys explosions.
         const double ws = World::get_BoxScale<double>();
         const double margin = 3.0;
         auto rnd = []() {
@@ -57,7 +61,6 @@ CelebrationSystem::tick(double dt, ParticleSystem& particle_sys)
             (rnd() * 2.0 - 1.0) * (ws - margin),
         };
 
-        // Random saturated hue. Convert HSV(h, 1, 1) to RGB cheaply.
         double h = rnd() * 6.0;
         int    i = static_cast<int>(h);
         double f = h - i;