afegit resource::cache

normalitzat Audio
This commit is contained in:
2026-04-18 11:41:34 +02:00
parent 7409c799c3
commit 94aa69cffe
29 changed files with 1420 additions and 134 deletions

View File

@@ -0,0 +1,55 @@
#include "scenes/boot_loader_scene.hpp"
#include "core/jail/jdraw8.hpp"
#include "core/resources/resource_cache.hpp"
namespace scenes {
namespace {
constexpr int SCREEN_W = 320;
constexpr Uint8 BG_COLOR = 0; // negre
constexpr Uint8 BAR_COLOR = 1; // blanc
constexpr int BAR_X = 60;
constexpr int BAR_Y = 170;
constexpr int BAR_W = SCREEN_W - (BAR_X * 2); // 200
constexpr int BAR_H = 6;
} // namespace
BootLoaderScene::BootLoaderScene() = default;
void BootLoaderScene::onEnter() {
// Inicialitza la paleta mínima per a la barra. La resta de
// colors queden a negre — després cada escena del joc carregarà
// la seua pròpia paleta.
JD8_SetPaletteColor(BG_COLOR, 0, 0, 0);
JD8_SetPaletteColor(BAR_COLOR, 63, 63, 63);
}
void BootLoaderScene::tick(int /*delta_ms*/) {
if (Resource::Cache::get()->loadStep(8)) {
done_ = true;
}
render();
}
void BootLoaderScene::render() const {
JD8_ClearScreen(BG_COLOR);
const float pct = Resource::Cache::get()->getProgress();
const int filled = static_cast<int>(static_cast<float>(BAR_W) * pct);
// Vora de la barra (línia 1 píxel a dalt i a baix).
JD8_FillRect(BAR_X - 1, BAR_Y - 1, BAR_W + 2, 1, BAR_COLOR);
JD8_FillRect(BAR_X - 1, BAR_Y + BAR_H, BAR_W + 2, 1, BAR_COLOR);
JD8_FillRect(BAR_X - 1, BAR_Y, 1, BAR_H, BAR_COLOR);
JD8_FillRect(BAR_X + BAR_W, BAR_Y, 1, BAR_H, BAR_COLOR);
// Ompliment proporcional al progrés.
if (filled > 0) {
JD8_FillRect(BAR_X, BAR_Y, filled, BAR_H, BAR_COLOR);
}
}
} // namespace scenes