fix: tidy scenes (slides/secreta enums UPPER_CASE) i mapa membres _
This commit is contained in:
+69
-69
@@ -7,102 +7,102 @@
|
||||
#include "core/jail/jinput.hpp"
|
||||
|
||||
Mapa::Mapa(Jd8::Surface gfx, Prota* sam) {
|
||||
this->gfx = gfx;
|
||||
this->sam = sam;
|
||||
this->gfx_ = gfx;
|
||||
this->sam_ = sam;
|
||||
|
||||
this->preparaFondoEstatic();
|
||||
this->preparaTombes();
|
||||
|
||||
this->ultim_vertex.columna = 255;
|
||||
this->frame_torxes = 0;
|
||||
this->ultim_vertex_.columna = 255;
|
||||
this->frame_torxes_ = 0;
|
||||
|
||||
this->farao = false;
|
||||
this->clau = false;
|
||||
this->porta_oberta = false;
|
||||
this->nova_momia = false;
|
||||
this->farao_ = false;
|
||||
this->clau_ = false;
|
||||
this->porta_oberta_ = false;
|
||||
this->nova_momia_ = false;
|
||||
}
|
||||
|
||||
Mapa::~Mapa() {
|
||||
Jd8::freeSurface(this->fondo);
|
||||
Jd8::freeSurface(this->fondo_);
|
||||
}
|
||||
|
||||
void Mapa::draw() {
|
||||
if (info::ctx.num_piramide != 4) {
|
||||
switch (sam->o) {
|
||||
switch (sam_->o) {
|
||||
case 0: // Down
|
||||
Jd8::blitCKToSurface(sam->x, sam->y, this->gfx, 15, 125 + sam->frame_pejades, 15, 1, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(sam_->x, sam_->y, this->gfx_, 15, 125 + sam_->frame_pejades, 15, 1, this->fondo_, 255);
|
||||
break;
|
||||
case 1: // Up
|
||||
Jd8::blitCKToSurface(sam->x, sam->y + 15, this->gfx, 0, 125 + (14 - sam->frame_pejades), 15, 1, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(sam_->x, sam_->y + 15, this->gfx_, 0, 125 + (14 - sam_->frame_pejades), 15, 1, this->fondo_, 255);
|
||||
break;
|
||||
case 2: // Right
|
||||
Jd8::blitCKToSurface(sam->x + 7, sam->y, this->gfx, 30 + sam->frame_pejades, 125, 1, 15, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(sam_->x + 7, sam_->y, this->gfx_, 30 + sam_->frame_pejades, 125, 1, 15, this->fondo_, 255);
|
||||
break;
|
||||
case 3: // Left
|
||||
Jd8::blitCKToSurface(sam->x + 8, sam->y, this->gfx, 45 + (14 - sam->frame_pejades), 125, 1, 15, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(sam_->x + 8, sam_->y, this->gfx_, 45 + (14 - sam_->frame_pejades), 125, 1, 15, this->fondo_, 255);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Jd8::blit(this->fondo);
|
||||
Jd8::blit(this->fondo_);
|
||||
|
||||
// Pinta tombes
|
||||
for (int y = 0; y < 4; y++) {
|
||||
for (int x = 0; x < 4; x++) {
|
||||
Jd8::blitCK(35 + (x * 65), 45 + (y * 35), this->gfx, this->tombes[x + (y * 4)].x, this->tombes[x + (y * 4)].y, 50, 20, 255);
|
||||
Jd8::blitCK(35 + (x * 65), 45 + (y * 35), this->gfx_, this->tombes[x + (y * 4)].x, this->tombes[x + (y * 4)].y, 50, 20, 255);
|
||||
}
|
||||
}
|
||||
|
||||
Jd8::blitCK(45, 15, this->gfx, 30 + (this->frame_torxes * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(95, 15, this->gfx, 30 + (this->frame_torxes * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(195, 15, this->gfx, 30 + (this->frame_torxes * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(245, 15, this->gfx, 30 + (this->frame_torxes * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(45, 15, this->gfx_, 30 + (this->frame_torxes_ * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(95, 15, this->gfx_, 30 + (this->frame_torxes_ * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(195, 15, this->gfx_, 30 + (this->frame_torxes_ * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(245, 15, this->gfx_, 30 + (this->frame_torxes_ * 25), 80, 25, 15, 255);
|
||||
};
|
||||
|
||||
void Mapa::update() {
|
||||
if (((sam->x - 20) % 65 == 0) && ((sam->y - 30) % 35 == 0) && ((this->ultim_vertex.columna != (sam->x - 20) / 65) || (this->ultim_vertex.fila != (sam->y - 30) / 35))) {
|
||||
this->vertex.columna = (sam->x - 20) / 65;
|
||||
this->vertex.fila = (sam->y - 30) / 35;
|
||||
if (this->ultim_vertex.columna != 255) {
|
||||
if (((sam_->x - 20) % 65 == 0) && ((sam_->y - 30) % 35 == 0) && ((this->ultim_vertex_.columna != (sam_->x - 20) / 65) || (this->ultim_vertex_.fila != (sam_->y - 30) / 35))) {
|
||||
this->vertex_.columna = (sam_->x - 20) / 65;
|
||||
this->vertex_.fila = (sam_->y - 30) / 35;
|
||||
if (this->ultim_vertex_.columna != 255) {
|
||||
this->comprovaUltimCami();
|
||||
}
|
||||
this->ultim_vertex = this->vertex;
|
||||
this->ultim_vertex_ = this->vertex_;
|
||||
}
|
||||
|
||||
if (this->porta_oberta && sam->x == 150 && sam->y == 30) {
|
||||
if (this->porta_oberta_ && sam_->x == 150 && sam_->y == 30) {
|
||||
if (Ji::keyPressed(SDL_SCANCODE_UP)) {
|
||||
this->sam->o = 4;
|
||||
this->sam->y -= 15;
|
||||
this->sam_->o = 4;
|
||||
this->sam_->y -= 15;
|
||||
}
|
||||
}
|
||||
|
||||
if (Jg::getCycleCounter() % 8 == 0) {
|
||||
this->frame_torxes++;
|
||||
this->frame_torxes = this->frame_torxes % 4;
|
||||
this->frame_torxes_++;
|
||||
this->frame_torxes_ = this->frame_torxes_ % 4;
|
||||
}
|
||||
}
|
||||
|
||||
auto Mapa::novaMomia() -> bool {
|
||||
bool resultat = nova_momia;
|
||||
nova_momia = false;
|
||||
bool resultat = nova_momia_;
|
||||
nova_momia_ = false;
|
||||
return resultat;
|
||||
}
|
||||
|
||||
void Mapa::preparaFondoEstatic() {
|
||||
// Prepara el fondo est�tic de l'habitaci�
|
||||
this->fondo = Jd8::newSurface();
|
||||
this->fondo_ = Jd8::newSurface();
|
||||
if (info::ctx.num_piramide == 6) {
|
||||
Jd8::blitToSurface(9, 2, this->gfx, 227, 185, 92, 7, this->fondo); // Text "SECRETA"
|
||||
Jd8::blitToSurface(9, 2, this->gfx_, 227, 185, 92, 7, this->fondo_); // Text "SECRETA"
|
||||
} else {
|
||||
Jd8::blitToSurface(9, 2, this->gfx, 60, 185, 39, 7, this->fondo); // Text "NIVELL"
|
||||
Jd8::blitToSurface(72, 6, this->gfx, 153, 189, 3, 1, this->fondo); // Ralleta entre num piramide i num habitacio
|
||||
Jd8::blitToSurface(9, 2, this->gfx_, 60, 185, 39, 7, this->fondo_); // Text "NIVELL"
|
||||
Jd8::blitToSurface(72, 6, this->gfx_, 153, 189, 3, 1, this->fondo_); // Ralleta entre num piramide i num habitacio
|
||||
}
|
||||
Jd8::blitToSurface(130, 2, this->gfx, 225, 192, 19, 8, this->fondo); // Montonet de monedes + signe '='
|
||||
Jd8::blitToSurface(220, 2, this->gfx, 160, 185, 48, 7, this->fondo); // Text "ENERGIA"
|
||||
Jd8::blitToSurface(130, 2, this->gfx_, 225, 192, 19, 8, this->fondo_); // Montonet de monedes + signe '='
|
||||
Jd8::blitToSurface(220, 2, this->gfx_, 160, 185, 48, 7, this->fondo_); // Text "ENERGIA"
|
||||
if (info::ctx.diners >= 200) {
|
||||
Jd8::blitToSurface(175, 3, this->gfx, 60, 193, 7, 6, this->fondo);
|
||||
Jd8::blitToSurface(175, 3, this->gfx_, 60, 193, 7, 6, this->fondo_);
|
||||
}
|
||||
|
||||
// Pinta taulells
|
||||
@@ -110,22 +110,22 @@ void Mapa::preparaFondoEstatic() {
|
||||
for (int x = 0; x < 19; x++) {
|
||||
switch (info::ctx.num_piramide) {
|
||||
case 1:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 0, 80, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 0, 80, 15, 15, this->fondo_);
|
||||
break;
|
||||
case 2:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 25, 95, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 25, 95, 15, 15, this->fondo_);
|
||||
break;
|
||||
case 3:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 40, 95, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 40, 95, 15, 15, this->fondo_);
|
||||
break;
|
||||
case 4:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 175 + ((rand() % 3) * 15), 80, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 175 + ((rand() % 3) * 15), 80, 15, 15, this->fondo_);
|
||||
break;
|
||||
case 5:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 130, 80, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 130, 80, 15, 15, this->fondo_);
|
||||
break;
|
||||
case 6:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 145, 80, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 145, 80, 15, 15, this->fondo_);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -134,28 +134,28 @@ void Mapa::preparaFondoEstatic() {
|
||||
}
|
||||
|
||||
// Pinta vores de les parets
|
||||
Jd8::blitCKToSurface(5, 15, this->gfx, 30, 110, 15, 15, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(295, 15, this->gfx, 45, 110, 15, 15, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(5, 180, this->gfx, 0, 155, 15, 20, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(295, 180, this->gfx, 15, 155, 15, 20, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(5, 15, this->gfx_, 30, 110, 15, 15, this->fondo_, 255);
|
||||
Jd8::blitCKToSurface(295, 15, this->gfx_, 45, 110, 15, 15, this->fondo_, 255);
|
||||
Jd8::blitCKToSurface(5, 180, this->gfx_, 0, 155, 15, 20, this->fondo_, 255);
|
||||
Jd8::blitCKToSurface(295, 180, this->gfx_, 15, 155, 15, 20, this->fondo_, 255);
|
||||
|
||||
// Pinta parets verticals
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Jd8::blitToSurface(5, 30 + (i * 15), this->gfx, 0, 110, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(295, 30 + (i * 15), this->gfx, 15, 110, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(5, 30 + (i * 15), this->gfx_, 0, 110, 15, 15, this->fondo_);
|
||||
Jd8::blitToSurface(295, 30 + (i * 15), this->gfx_, 15, 110, 15, 15, this->fondo_);
|
||||
}
|
||||
|
||||
// Pinta parets hortzintals
|
||||
for (int i = 0; i < 11; i++) {
|
||||
Jd8::blitToSurface(20 + (i * 25), 185, this->gfx, 0, 95, 25, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (i * 25), 15, this->gfx, 0, 95, 25, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (i * 25), 185, this->gfx_, 0, 95, 25, 15, this->fondo_);
|
||||
Jd8::blitToSurface(20 + (i * 25), 15, this->gfx_, 0, 95, 25, 15, this->fondo_);
|
||||
}
|
||||
|
||||
// Pinta la porta
|
||||
Jd8::blitCKToSurface(150, 18, this->gfx, 0, 143, 15, 12, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(150, 18, this->gfx_, 0, 143, 15, 12, this->fondo_, 255);
|
||||
|
||||
if (info::ctx.num_piramide == 2) {
|
||||
Jd8::blitToSurface(5, 100, this->gfx, 30, 140, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(5, 100, this->gfx_, 30, 140, 15, 15, this->fondo_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,12 +204,12 @@ auto minim(Uint8 a, Uint8 b) -> Uint8 {
|
||||
}
|
||||
|
||||
void Mapa::comprovaUltimCami() {
|
||||
Uint8 col_aux = abs(this->vertex.columna - this->ultim_vertex.columna);
|
||||
Uint8 fil_aux = abs(this->vertex.fila - this->ultim_vertex.fila);
|
||||
Uint8 col_aux = abs(this->vertex_.columna - this->ultim_vertex_.columna);
|
||||
Uint8 fil_aux = abs(this->vertex_.fila - this->ultim_vertex_.fila);
|
||||
|
||||
if (col_aux > fil_aux) { // Cam� horitzontal
|
||||
Uint8 cami_fila = this->vertex.fila;
|
||||
Uint8 cami_columna = minim(this->vertex.columna, this->ultim_vertex.columna);
|
||||
Uint8 cami_fila = this->vertex_.fila;
|
||||
Uint8 cami_columna = minim(this->vertex_.columna, this->ultim_vertex_.columna);
|
||||
|
||||
Sint8 caixa_avall = (cami_fila << 2) + cami_columna;
|
||||
Sint8 caixa_amunt = caixa_avall - 4;
|
||||
@@ -223,8 +223,8 @@ void Mapa::comprovaUltimCami() {
|
||||
this->comprovaCaixa(caixa_amunt);
|
||||
}
|
||||
} else { // Cam� vertical
|
||||
Uint8 cami_columna = this->vertex.columna;
|
||||
Uint8 cami_fila = minim(this->vertex.fila, this->ultim_vertex.fila);
|
||||
Uint8 cami_columna = this->vertex_.columna;
|
||||
Uint8 cami_fila = minim(this->vertex_.fila, this->ultim_vertex_.fila);
|
||||
|
||||
Sint8 caixa_dreta = (cami_fila << 2) + cami_columna;
|
||||
Sint8 caixa_esquerra = caixa_dreta - 1;
|
||||
@@ -265,26 +265,26 @@ void Mapa::comprovaCaixa(Uint8 num) {
|
||||
break;
|
||||
case CONTE_FARAO:
|
||||
this->tombes[num].x = 150;
|
||||
this->farao = true;
|
||||
this->farao_ = true;
|
||||
break;
|
||||
case CONTE_CLAU:
|
||||
this->tombes[num].x = 200;
|
||||
this->clau = true;
|
||||
this->clau_ = true;
|
||||
break;
|
||||
case CONTE_MOMIA:
|
||||
this->tombes[num].y = 175;
|
||||
this->nova_momia = true;
|
||||
this->nova_momia_ = true;
|
||||
break;
|
||||
case CONTE_PERGAMI:
|
||||
this->tombes[num].x = 250;
|
||||
this->sam->pergami = true;
|
||||
this->sam_->pergami = true;
|
||||
break;
|
||||
case CONTE_DIAMANT:
|
||||
this->tombes[num].y = 70;
|
||||
info::ctx.diamants++;
|
||||
info::ctx.diners += VALOR_DIAMANT;
|
||||
if (info::ctx.diamants == 16) {
|
||||
this->farao = this->clau = true;
|
||||
this->farao_ = this->clau_ = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -295,8 +295,8 @@ void Mapa::comprovaCaixa(Uint8 num) {
|
||||
}
|
||||
|
||||
void Mapa::comprovaPorta() {
|
||||
if (this->clau && this->farao) {
|
||||
Jd8::blitCKToSurface(150, 18, this->gfx, 15, 143, 15, 12, this->fondo, 255);
|
||||
porta_oberta = true;
|
||||
if (this->clau_ && this->farao_) {
|
||||
Jd8::blitCKToSurface(150, 18, this->gfx_, 15, 143, 15, 12, this->fondo_, 255);
|
||||
porta_oberta_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -53,16 +53,16 @@ class Mapa {
|
||||
void comprovaUltimCami();
|
||||
void comprovaPorta();
|
||||
|
||||
Jd8::Surface gfx;
|
||||
Jd8::Surface fondo;
|
||||
Vertex vertex;
|
||||
Vertex ultim_vertex;
|
||||
Uint8 frame_torxes;
|
||||
Jd8::Surface gfx_;
|
||||
Jd8::Surface fondo_;
|
||||
Vertex vertex_;
|
||||
Vertex ultim_vertex_;
|
||||
Uint8 frame_torxes_;
|
||||
|
||||
Prota* sam;
|
||||
Prota* sam_;
|
||||
|
||||
bool farao;
|
||||
bool clau;
|
||||
bool porta_oberta;
|
||||
bool nova_momia;
|
||||
bool farao_;
|
||||
bool clau_;
|
||||
bool porta_oberta_;
|
||||
bool nova_momia_;
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace scenes {
|
||||
pal_active_ = new Color[256];
|
||||
std::memcpy(pal_active_, pal_aux_, 768);
|
||||
|
||||
phase_ = Phase::InitialFadeOut;
|
||||
phase_ = Phase::INITIAL_FADE_OUT;
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
|
||||
@@ -78,20 +78,20 @@ namespace scenes {
|
||||
void SecretaScene::beginFinalFade() {
|
||||
Audio::get()->fadeOutMusic(250);
|
||||
fade_.startFadeOut();
|
||||
phase_ = Phase::FinalFadeOut;
|
||||
phase_ = Phase::FINAL_FADE_OUT;
|
||||
}
|
||||
|
||||
void SecretaScene::tick(int delta_ms) {
|
||||
// Skip per tecla (després del fade inicial, no mentre). Salta
|
||||
// directament al FinalFadeOut. Mateix patró que el vell, on
|
||||
// directament al FINAL_FADE_OUT. Mateix patró que el vell, on
|
||||
// qualsevol tecla sortia del loop.
|
||||
if (!skip_triggered_ && phase_ != Phase::InitialFadeOut && Ji::anyKey()) {
|
||||
if (!skip_triggered_ && phase_ != Phase::INITIAL_FADE_OUT && Ji::anyKey()) {
|
||||
skip_triggered_ = true;
|
||||
beginFinalFade();
|
||||
}
|
||||
|
||||
switch (phase_) {
|
||||
case Phase::InitialFadeOut:
|
||||
case Phase::INITIAL_FADE_OUT:
|
||||
fade_.tick(delta_ms);
|
||||
if (fade_.done()) {
|
||||
// Ara main_palette (la vella) té tots els canals a 0.
|
||||
@@ -100,12 +100,12 @@ namespace scenes {
|
||||
// futures escriptures a pal_active_ afecten la pantalla.
|
||||
Jd8::setScreenPalette(pal_active_);
|
||||
Jd8::clearScreen(255);
|
||||
phase_ = Phase::Tomba1ScrollIn;
|
||||
phase_ = Phase::TOMBA1_SCROLL_IN;
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::Tomba1ScrollIn: {
|
||||
case Phase::TOMBA1_SCROLL_IN: {
|
||||
phase_acc_ms_ += delta_ms;
|
||||
const int contador = std::min(128, (phase_acc_ms_ / TICK_MS) + 1);
|
||||
// Dos blits solapats: el primer avança a velocitat completa,
|
||||
@@ -113,63 +113,63 @@ namespace scenes {
|
||||
Jd8::blit(70, 60, gfx_, 0, contador, 178, 70);
|
||||
Jd8::blitCK(70, 60, gfx_, 178, contador >> 1, 142, 70, 255);
|
||||
if (phase_acc_ms_ >= TOMBA1_SCROLL_MS) {
|
||||
phase_ = Phase::Tomba1Hold;
|
||||
phase_ = Phase::TOMBA1_HOLD;
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Phase::Tomba1Hold:
|
||||
case Phase::TOMBA1_HOLD:
|
||||
phase_acc_ms_ += delta_ms;
|
||||
if (phase_acc_ms_ >= TOMBA1_HOLD_MS) {
|
||||
swapToTomba2();
|
||||
phase_ = Phase::Tomba2ScrollIn;
|
||||
phase_ = Phase::TOMBA2_SCROLL_IN;
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::Tomba2ScrollIn: {
|
||||
case Phase::TOMBA2_SCROLL_IN: {
|
||||
phase_acc_ms_ += delta_ms;
|
||||
const int contador = std::min(94, (phase_acc_ms_ / TICK_MS) + 1);
|
||||
Jd8::blit(55, 53, gfx_, 0, 158 - contador, 211, contador);
|
||||
if (phase_acc_ms_ >= TOMBA2_SCROLL_MS) {
|
||||
phase_ = Phase::Tomba2Hold;
|
||||
phase_ = Phase::TOMBA2_HOLD;
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Phase::Tomba2Hold:
|
||||
case Phase::TOMBA2_HOLD:
|
||||
phase_acc_ms_ += delta_ms;
|
||||
if (phase_acc_ms_ >= TOMBA2_HOLD_MS) {
|
||||
beginRedPulseSetup();
|
||||
phase_ = Phase::Tomba2Reveal;
|
||||
phase_ = Phase::TOMBA2_REVEAL;
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::Tomba2Reveal: {
|
||||
case Phase::TOMBA2_REVEAL: {
|
||||
phase_acc_ms_ += delta_ms;
|
||||
const int contador = std::min(80, (phase_acc_ms_ / TICK_MS) + 1);
|
||||
// Revelat horitzontal simètric: l'amplada creix 2px per tick
|
||||
// i el src_x es desplaça a l'esquerra el mateix.
|
||||
Jd8::blit(80, 68, gfx_, 160 - (contador * 2), 0, contador * 2, 64);
|
||||
if (phase_acc_ms_ >= TOMBA2_REVEAL_MS) {
|
||||
phase_ = Phase::Tomba2RevealHold;
|
||||
phase_ = Phase::TOMBA2_REVEAL_HOLD;
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Phase::Tomba2RevealHold:
|
||||
case Phase::TOMBA2_REVEAL_HOLD:
|
||||
phase_acc_ms_ += delta_ms;
|
||||
if (phase_acc_ms_ >= TOMBA2_REVEAL_HOLD_MS) {
|
||||
phase_ = Phase::RedPulse;
|
||||
phase_ = Phase::RED_PULSE;
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::RedPulse: {
|
||||
case Phase::RED_PULSE: {
|
||||
phase_acc_ms_ += delta_ms;
|
||||
const int contador = std::min(51, phase_acc_ms_ / TICK_MS);
|
||||
// Anima el canal R dels índexs 254 i 253 (aquest a la meitat
|
||||
@@ -177,27 +177,27 @@ namespace scenes {
|
||||
Jd8::setPaletteColor(254, contador + 12, 11, 11);
|
||||
Jd8::setPaletteColor(253, (contador + 12) >> 1, 11, 11);
|
||||
if (phase_acc_ms_ >= RED_PULSE_MS) {
|
||||
phase_ = Phase::RedPulseHold;
|
||||
phase_ = Phase::RED_PULSE_HOLD;
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Phase::RedPulseHold:
|
||||
case Phase::RED_PULSE_HOLD:
|
||||
phase_acc_ms_ += delta_ms;
|
||||
if (phase_acc_ms_ >= RED_PULSE_HOLD_MS) {
|
||||
beginFinalFade();
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::FinalFadeOut:
|
||||
case Phase::FINAL_FADE_OUT:
|
||||
fade_.tick(delta_ms);
|
||||
if (fade_.done()) {
|
||||
phase_ = Phase::Done;
|
||||
phase_ = Phase::DONE;
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::Done:
|
||||
case Phase::DONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,22 +33,22 @@ namespace scenes {
|
||||
|
||||
void onEnter() override;
|
||||
void tick(int delta_ms) override;
|
||||
[[nodiscard]] auto done() const -> bool override { return phase_ == Phase::Done; }
|
||||
[[nodiscard]] auto done() const -> bool override { return phase_ == Phase::DONE; }
|
||||
[[nodiscard]] auto nextState() const -> int override { return 0; }
|
||||
|
||||
private:
|
||||
enum class Phase : std::uint8_t {
|
||||
InitialFadeOut,
|
||||
Tomba1ScrollIn,
|
||||
Tomba1Hold,
|
||||
Tomba2ScrollIn,
|
||||
Tomba2Hold,
|
||||
Tomba2Reveal,
|
||||
Tomba2RevealHold,
|
||||
RedPulse,
|
||||
RedPulseHold,
|
||||
FinalFadeOut,
|
||||
Done,
|
||||
INITIAL_FADE_OUT,
|
||||
TOMBA1_SCROLL_IN,
|
||||
TOMBA1_HOLD,
|
||||
TOMBA2_SCROLL_IN,
|
||||
TOMBA2_HOLD,
|
||||
TOMBA2_REVEAL,
|
||||
TOMBA2_REVEAL_HOLD,
|
||||
RED_PULSE,
|
||||
RED_PULSE_HOLD,
|
||||
FINAL_FADE_OUT,
|
||||
DONE,
|
||||
};
|
||||
|
||||
void swapToTomba2();
|
||||
@@ -60,7 +60,7 @@ namespace scenes {
|
||||
Jd8::Palette pal_active_{nullptr}; // propietat transferida a main_palette
|
||||
PaletteFade fade_;
|
||||
|
||||
Phase phase_{Phase::InitialFadeOut};
|
||||
Phase phase_{Phase::INITIAL_FADE_OUT};
|
||||
int phase_acc_ms_{0};
|
||||
bool skip_triggered_{false};
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace scenes {
|
||||
|
||||
Jd8::clearScreen(BG_COLOR_INDEX);
|
||||
|
||||
phase_ = Phase::Slide1Enter;
|
||||
phase_ = Phase::SLIDE1_ENTER;
|
||||
phase_acc_ms_ = 0;
|
||||
next_state_ = 0;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace scenes {
|
||||
Audio::get()->fadeOutMusic(250);
|
||||
}
|
||||
fade_.startFadeOut();
|
||||
phase_ = Phase::FadeFinal;
|
||||
phase_ = Phase::FADE_FINAL;
|
||||
}
|
||||
|
||||
void SlidesScene::tick(int delta_ms) {
|
||||
@@ -109,18 +109,18 @@ namespace scenes {
|
||||
Audio::get()->fadeOutMusic(250);
|
||||
}
|
||||
fade_.startFadeOut();
|
||||
phase_ = Phase::FadeFinal;
|
||||
phase_ = Phase::FADE_FINAL;
|
||||
}
|
||||
|
||||
switch (phase_) {
|
||||
case Phase::Slide1Enter:
|
||||
case Phase::Slide2Enter:
|
||||
case Phase::Slide3Enter: {
|
||||
case Phase::SLIDE1_ENTER:
|
||||
case Phase::SLIDE2_ENTER:
|
||||
case Phase::SLIDE3_ENTER: {
|
||||
phase_acc_ms_ += delta_ms;
|
||||
int slide_idx = 2;
|
||||
if (phase_ == Phase::Slide1Enter) {
|
||||
if (phase_ == Phase::SLIDE1_ENTER) {
|
||||
slide_idx = 0;
|
||||
} else if (phase_ == Phase::Slide2Enter) {
|
||||
} else if (phase_ == Phase::SLIDE2_ENTER) {
|
||||
slide_idx = 1;
|
||||
}
|
||||
const float t = std::min(1.0F, static_cast<float>(phase_acc_ms_) / static_cast<float>(SCROLL_MS));
|
||||
@@ -131,55 +131,55 @@ namespace scenes {
|
||||
if (phase_acc_ms_ >= SCROLL_MS) {
|
||||
// Garanteix posició final exacta (pos_x=0).
|
||||
drawSlide(slide_idx, 0);
|
||||
if (phase_ == Phase::Slide1Enter) {
|
||||
phase_ = Phase::Slide1Hold;
|
||||
} else if (phase_ == Phase::Slide2Enter) {
|
||||
phase_ = Phase::Slide2Hold;
|
||||
if (phase_ == Phase::SLIDE1_ENTER) {
|
||||
phase_ = Phase::SLIDE1_HOLD;
|
||||
} else if (phase_ == Phase::SLIDE2_ENTER) {
|
||||
phase_ = Phase::SLIDE2_HOLD;
|
||||
} else {
|
||||
phase_ = Phase::Slide3Hold;
|
||||
phase_ = Phase::SLIDE3_HOLD;
|
||||
}
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Phase::Slide1Hold:
|
||||
case Phase::Slide2Hold:
|
||||
case Phase::SLIDE1_HOLD:
|
||||
case Phase::SLIDE2_HOLD:
|
||||
phase_acc_ms_ += delta_ms;
|
||||
if (phase_acc_ms_ >= HOLD_MS) {
|
||||
fade_.startFadeOut();
|
||||
if (phase_ == Phase::Slide1Hold) {
|
||||
phase_ = Phase::FadeOut1;
|
||||
if (phase_ == Phase::SLIDE1_HOLD) {
|
||||
phase_ = Phase::FADE_OUT1;
|
||||
} else {
|
||||
phase_ = Phase::FadeOut2;
|
||||
phase_ = Phase::FADE_OUT2;
|
||||
}
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::Slide3Hold:
|
||||
case Phase::SLIDE3_HOLD:
|
||||
phase_acc_ms_ += delta_ms;
|
||||
if (phase_acc_ms_ >= HOLD_MS) {
|
||||
beginFinalFade();
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::FadeOut1:
|
||||
case Phase::FadeOut2:
|
||||
case Phase::FADE_OUT1:
|
||||
case Phase::FADE_OUT2:
|
||||
fade_.tick(delta_ms);
|
||||
if (fade_.done()) {
|
||||
restorePalette();
|
||||
Jd8::clearScreen(BG_COLOR_INDEX);
|
||||
if (phase_ == Phase::FadeOut1) {
|
||||
phase_ = Phase::Slide2Enter;
|
||||
if (phase_ == Phase::FADE_OUT1) {
|
||||
phase_ = Phase::SLIDE2_ENTER;
|
||||
} else {
|
||||
phase_ = Phase::Slide3Enter;
|
||||
phase_ = Phase::SLIDE3_ENTER;
|
||||
}
|
||||
phase_acc_ms_ = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::FadeFinal:
|
||||
case Phase::FADE_FINAL:
|
||||
fade_.tick(delta_ms);
|
||||
if (fade_.done()) {
|
||||
if (num_piramide_at_start_ == 7) {
|
||||
@@ -188,11 +188,11 @@ namespace scenes {
|
||||
} else {
|
||||
next_state_ = 0;
|
||||
}
|
||||
phase_ = Phase::Done;
|
||||
phase_ = Phase::DONE;
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::Done:
|
||||
case Phase::DONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,18 +18,18 @@ namespace scenes {
|
||||
// - altre cas (num_piramide == 1): gfx/intro.gif, sense música nova
|
||||
//
|
||||
// Flux:
|
||||
// Slide1Enter (1600 ms scroll dreta→centre, easing outCubic)
|
||||
// → Slide1Hold (4600 ms)
|
||||
// → FadeOut1 + clear + reset paleta
|
||||
// → Slide2Enter (1600 ms scroll esquerra→centre)
|
||||
// → Slide2Hold (4600 ms)
|
||||
// → FadeOut2 + clear + reset paleta
|
||||
// → Slide3Enter (1600 ms scroll dreta→centre)
|
||||
// → Slide3Hold (4600 ms)
|
||||
// → FadeFinal (Ja::fadeOutMusic si num_piramide != 7 + fade paleta)
|
||||
// SLIDE1_ENTER (1600 ms scroll dreta→centre, easing outCubic)
|
||||
// → SLIDE1_HOLD (4600 ms)
|
||||
// → FADE_OUT1 + clear + reset paleta
|
||||
// → SLIDE2_ENTER (1600 ms scroll esquerra→centre)
|
||||
// → SLIDE2_HOLD (4600 ms)
|
||||
// → FADE_OUT2 + clear + reset paleta
|
||||
// → SLIDE3_ENTER (1600 ms scroll dreta→centre)
|
||||
// → SLIDE3_HOLD (4600 ms)
|
||||
// → FADE_FINAL (Ja::fadeOutMusic si num_piramide != 7 + fade paleta)
|
||||
// → Done
|
||||
//
|
||||
// Qualsevol tecla salta directament a FadeFinal (sense cortar la música
|
||||
// Qualsevol tecla salta directament a FADE_FINAL (sense cortar la música
|
||||
// si hem entrat per num_piramide==7, per fidelitat al vell).
|
||||
//
|
||||
// NextState:
|
||||
@@ -42,21 +42,21 @@ namespace scenes {
|
||||
|
||||
void onEnter() override;
|
||||
void tick(int delta_ms) override;
|
||||
[[nodiscard]] auto done() const -> bool override { return phase_ == Phase::Done; }
|
||||
[[nodiscard]] auto done() const -> bool override { return phase_ == Phase::DONE; }
|
||||
[[nodiscard]] auto nextState() const -> int override { return next_state_; }
|
||||
|
||||
private:
|
||||
enum class Phase : std::uint8_t {
|
||||
Slide1Enter,
|
||||
Slide1Hold,
|
||||
FadeOut1,
|
||||
Slide2Enter,
|
||||
Slide2Hold,
|
||||
FadeOut2,
|
||||
Slide3Enter,
|
||||
Slide3Hold,
|
||||
FadeFinal,
|
||||
Done,
|
||||
SLIDE1_ENTER,
|
||||
SLIDE1_HOLD,
|
||||
FADE_OUT1,
|
||||
SLIDE2_ENTER,
|
||||
SLIDE2_HOLD,
|
||||
FADE_OUT2,
|
||||
SLIDE3_ENTER,
|
||||
SLIDE3_HOLD,
|
||||
FADE_FINAL,
|
||||
DONE,
|
||||
};
|
||||
|
||||
// Pinta un slide amb desplaçament horitzontal. `slide_idx` = 0..2
|
||||
@@ -71,7 +71,7 @@ namespace scenes {
|
||||
Jd8::Palette pal_active_{nullptr}; // propietat transferida a main_palette
|
||||
PaletteFade fade_;
|
||||
|
||||
Phase phase_{Phase::Slide1Enter};
|
||||
Phase phase_{Phase::SLIDE1_ENTER};
|
||||
int phase_acc_ms_{0};
|
||||
int num_piramide_at_start_{1};
|
||||
int next_state_{0};
|
||||
|
||||
Reference in New Issue
Block a user