feat(effects): heat-haze sinusoidal al fons del títol (configurable a ui.yaml)

This commit is contained in:
JailDesigner committed 2026-05-06 11:48:29 +02:00
1 parent 9233bd8d75
commit 1fc3ab8e31
9 files changed
+150 -3

No files matched your search

+16 -3
View File
@@ -56,6 +56,14 @@ TitleScene::TitleScene(std::shared_ptr<Text> display_font, std::shared_ptr<Text>
next_factory_(std::move(next_factory)),
timer_ms_(UiConfig::get().titleDurationMs()) {
std::cout << "[scene] " << SCENE_NAME << " start\n";
const auto& hh = UiConfig::get().titleHeatHaze();
if (hh.enabled) {
heat_haze_.emplace(Effects::HeatHaze::Params{
.amplitude_px = hh.amplitude_px,
.wavelength_px = hh.wavelength_px,
.speed_hz = hh.speed_hz,
});
}
}
TitleScene::~TitleScene() = default;
@@ -69,6 +77,7 @@ void TitleScene::update(int delta_ms) {
timer_ms_ -= delta_ms;
blink_elapsed_ms_ += delta_ms;
if (heat_haze_) { heat_haze_->tick(delta_ms); }
const bool SKIPPED = std::ranges::any_of(EventBuffer::events, [](const SDL_Event& ev) {
return ev.type == SDL_EVENT_KEY_DOWN && !Placeholder::isReservedScancode(ev.key.scancode);
@@ -87,10 +96,14 @@ void TitleScene::render() {
const auto& palette = Resource::Cache::get().getPalette("ui");
// Fons: la imatge si està disponible (cobreix tot el canvas amb la
// seua paleta nadiua); en cas contrari, color pla de la paleta UI
// com a fallback defensiu.
// seua paleta nadiua), opcionalment amb heat-haze; en cas contrari,
// color pla de la paleta UI com a fallback defensiu.
if (background_) {
background_->render(0, 0);
if (heat_haze_) {
heat_haze_->render(*background_, 0, 0);
} else {
background_->render(0, 0);
}
} else {
Screen::get().fillRect(0, 0, GameCanvas::WIDTH, GameCanvas::HEIGHT, palette[ui_config.titleBgColor()]);
}
+3
View File
@@ -2,7 +2,9 @@
#include <functional>
#include <memory>
#include <optional>
#include "core/rendering/effects/heat_haze.hpp"
#include "core/scene/scene.hpp"
class Surface;
@@ -30,4 +32,5 @@ class TitleScene : public Scene {
SceneFactory next_factory_;
int timer_ms_;
int blink_elapsed_ms_{0};
std::optional<Effects::HeatHaze> heat_haze_;
};