step 9: intro_sprites_scene com a sub-escena (elimina doIntroSprites + 3 variants aleatòries)
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
#include "game/modulesequence.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "core/jail/jdraw8.hpp"
|
||||
#include "core/jail/jgame.hpp"
|
||||
#include "core/jail/jinput.hpp"
|
||||
#include "game/options.hpp"
|
||||
|
||||
ModuleSequence::ModuleSequence() {
|
||||
}
|
||||
@@ -13,20 +9,6 @@ ModuleSequence::ModuleSequence() {
|
||||
ModuleSequence::~ModuleSequence(void) {
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Espera fins que passe el tick de JG_ShouldUpdate o fins que el jugador
|
||||
// polse qualsevol tecla. Torna `true` si la seqüència s'ha de cancel·lar.
|
||||
// Centralitza el patró repetit de les cinemàtiques; a la Fase 5 (quan
|
||||
// eliminem el game thread) passarà a ser un pas de màquina d'estats real.
|
||||
bool wait_frame_or_skip() {
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int ModuleSequence::Go() {
|
||||
if (info::ctx.num_piramide == 6 && info::ctx.diners < 200) info::ctx.num_piramide = 7;
|
||||
|
||||
@@ -38,6 +20,7 @@ int ModuleSequence::Go() {
|
||||
// case 8 (Credits) → scenes::CreditsScene
|
||||
// case 100 (Mort) → scenes::MortScene
|
||||
// case 255 (Intro) → scenes::IntroScene / scenes::IntroNewLogoScene
|
||||
// (amb scenes::IntroSpritesScene com a sub-escena)
|
||||
// El gameFiberEntry les dispatcha via SceneRegistry abans de caure a
|
||||
// aquest Go() — així que en la pràctica ja no s'arriba ací. El codi
|
||||
// que queda sota (JD8_FadeOut + transicions de num_piramide) serà
|
||||
@@ -53,8 +36,6 @@ int ModuleSequence::Go() {
|
||||
return 1;
|
||||
} else if (info::ctx.num_piramide == 0) {
|
||||
info::ctx.num_piramide = 1;
|
||||
// info::ctx.num_piramide = 6;
|
||||
// info::ctx.diners = 200;
|
||||
return 1;
|
||||
} else if (info::ctx.num_piramide == 7) {
|
||||
info::ctx.num_piramide = 8;
|
||||
@@ -69,533 +50,4 @@ int ModuleSequence::Go() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int minim(const int a, const int b) {
|
||||
if (b < a) {
|
||||
return b;
|
||||
} else {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
// Pinta el wordmark JAILGAMES/Jailgames en el mateix lloc (y=78) durant les
|
||||
// animacions de sprites de l'intro. Branqueja entre logo vell i nou segons
|
||||
// Options::game.use_new_logo.
|
||||
static void drawIntroWordmark(JD8_Surface gfx) {
|
||||
if (Options::game.use_new_logo) {
|
||||
JD8_Blit(60, 78, gfx, 60, 158, 188, 28);
|
||||
} else {
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleSequence::doIntroSprites(JD8_Surface gfx) {
|
||||
JG_SetUpdateTicks(20);
|
||||
|
||||
Uint16 fr1 = 13;
|
||||
Uint16 fr2 = fr1;
|
||||
Uint16 fr3 = 11;
|
||||
Uint16 fr4 = fr3;
|
||||
Uint16 fr5 = 20;
|
||||
Uint16 fr6 = 8;
|
||||
Uint16 fr7 = 29;
|
||||
Uint16 fr8 = 4;
|
||||
Uint16 fr9 = 16;
|
||||
Uint16 fr10 = fr9;
|
||||
Uint16 fr11 = 6;
|
||||
Uint16 creu = 75;
|
||||
Uint16 interrogant = 90;
|
||||
|
||||
Uint16 fr_ani_1[13]; // camina dreta
|
||||
Uint16 fr_ani_2[13]; // camina esquerra
|
||||
Uint16 fr_ani_3[11]; // trau el mapa DRETA
|
||||
Uint16 fr_ani_4[11]; // trau el mapa ESQUERRA
|
||||
Uint16 fr_ani_5[20]; // bot de susto
|
||||
Uint16 fr_ani_6[8]; // momia
|
||||
Uint16 fr_ani_7[29]; // deixa caure el PAPER i SOMBRA
|
||||
Uint16 fr_ani_8[4]; // PEDRA
|
||||
Uint16 fr_ani_9[16]; // prota BALL
|
||||
Uint16 fr_ani_10[16]; // momia BALL
|
||||
Uint16 fr_ani_11[6]; // altaveu
|
||||
|
||||
for (int i = 0; i < fr1; i++) fr_ani_1[i] = i * 15;
|
||||
for (int i = 0; i < fr2; i++) fr_ani_2[i] = i * 15; // 15
|
||||
for (int i = 0; i < fr3; i++) fr_ani_3[i] = i * 15; // 30
|
||||
for (int i = 0; i < fr4; i++) fr_ani_4[i] = i * 15; // 45
|
||||
for (int i = 0; i <= 9; i++) fr_ani_5[i] = (i + 11) * 15; // 45
|
||||
for (int i = 10; i <= 19; i++) fr_ani_5[i] = fr_ani_5[19 - i];
|
||||
for (int i = 0; i < fr6; i++) fr_ani_6[i] = i * 15; // 60
|
||||
for (int i = 0; i <= 13; i++) fr_ani_7[i] = (i + 5) * 15; // 75
|
||||
for (int i = 14; i < fr7; i++) fr_ani_7[i] = (i - 14) * 15; // 105
|
||||
for (int i = 0; i < fr8; i++) fr_ani_8[i] = (i + 1) * 15; // 75
|
||||
for (int i = 0; i < fr9; i++) fr_ani_9[i] = i * 15; // 120
|
||||
for (int i = 0; i < fr10; i++) fr_ani_10[i] = i * 15; // 135
|
||||
for (int i = 0; i < fr11; i++) fr_ani_11[i] = (i + 1) * 15; // 90
|
||||
fr_ani_11[fr11 - 1] = fr_ani_11[3];
|
||||
|
||||
switch (rand() % 3) {
|
||||
case 0:
|
||||
|
||||
// camina cap a la DRETA }
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_1[(i div 5) mod fr1],15,15,i,150);
|
||||
JD8_BlitCK(i, 150, gfx, fr_ani_1[(i / 5) % fr1], 0, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// trau el MAPA DRETA }
|
||||
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_3[minim((i div 5),fr3-1)],15,15,200,150);
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_3[minim((i / 5), fr3 - 1)], 30, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// guarda el MAPA }
|
||||
|
||||
for (int i = 200; i >= 0; i--) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_3[minim((i div 5),fr3-1)],15,15,200,150);
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_3[minim((i / 5), fr3 - 1)], 30, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// camina cap a la ESQUERRA }
|
||||
|
||||
for (int i = 200; i >= 80; i--) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_2[(i div 5) mod fr2],15,15,i,150);
|
||||
JD8_BlitCK(i, 150, gfx, fr_ani_2[(i / 5) % fr2], 15, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// trau el MAPA ESQUERRA }
|
||||
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_4[minim((i div 5),fr4-1)],15,15,80,150);
|
||||
JD8_BlitCK(80, 150, gfx, fr_ani_4[minim((i / 5), fr4 - 1)], 45, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// momia cap a la ESQUERRA }
|
||||
|
||||
for (int i = 300; i >= 95; i--) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_6[(i div 10) mod fr6],15,15,i,150);
|
||||
JD8_BlitCK(i, 150, gfx, fr_ani_6[(i / 5) % fr6], 60, 15, 15, 0);
|
||||
// Put_sprite(from,where,fr_ani_4[fr4-1],15,15,80,150);
|
||||
JD8_BlitCK(80, 150, gfx, fr_ani_4[fr4 - 1], 45, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// girar-se }
|
||||
|
||||
for (int i = 0; i <= 50; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_1[1],15,15,80,150);
|
||||
JD8_BlitCK(80, 150, gfx, fr_ani_1[1], 0, 15, 15, 0);
|
||||
// Put_sprite(from,where,fr_ani_6[4],15,15,95,150);
|
||||
JD8_BlitCK(95, 150, gfx, fr_ani_6[4], 60, 15, 15, 0);
|
||||
// Put_sprite(from,where,interrogant,15,15,80,133);
|
||||
JD8_BlitCK(80, 133, gfx, 0, interrogant, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// bot de SUSTO }
|
||||
|
||||
for (int i = 0; i <= 49; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_5[minim((i div 5),fr5-1)],15,15,80,150-((i mod 50) div 5));
|
||||
JD8_BlitCK(80, 150 - ((i % 50) / 5), gfx, fr_ani_5[minim(i / 5, fr5 - 1)], 45, 15, 15, 0);
|
||||
// Put_sprite(from,where,fr_ani_6[4],15,15,95,150);
|
||||
JD8_BlitCK(95, 150, gfx, fr_ani_6[4], 60, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// bot de SUSTO }
|
||||
|
||||
for (int i = 50; i <= 99; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_5[minim((i div 5),fr5-1)],15,15,80,140+((i mod 50) div 5));
|
||||
JD8_BlitCK(80, 140 + ((i % 50) / 5), gfx, fr_ani_5[minim(i / 5, fr5 - 1)], 45, 15, 15, 0);
|
||||
// Put_sprite(from,where,fr_ani_6[4],15,15,95,150);
|
||||
JD8_BlitCK(95, 150, gfx, fr_ani_6[4], 60, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// camina cap a la ESQUERRA }
|
||||
|
||||
for (int i = 80; i >= 0; i--) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_2[(i div 5) mod fr2],15,15,i,150);
|
||||
JD8_BlitCK(i, 150, gfx, fr_ani_2[(i / 5) % fr2], 15, 15, 15, 0);
|
||||
// Put_sprite(from,where,fr_ani_6[4],15,15,95,150);
|
||||
JD8_BlitCK(95, 150, gfx, fr_ani_6[4], 60, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// final }
|
||||
|
||||
for (int i = 0; i <= 150; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_6[4],15,15,95,150);
|
||||
JD8_BlitCK(95, 150, gfx, fr_ani_6[4], 60, 15, 15, 0);
|
||||
// Put_sprite(from,where,interrogant,15,15,95,133);
|
||||
JD8_BlitCK(95, 133, gfx, 0, interrogant, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
}
|
||||
//-----}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
// camina cap a la DRETA }
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
JD8_BlitCK(200, 155, gfx, 0, creu, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_1[(i div 5) mod fr1],15,15,i,150);
|
||||
JD8_BlitCK(i, 150, gfx, fr_ani_1[(i / 5) % fr1], 0, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// trau el MAPA DRETA }
|
||||
|
||||
for (int i = 0; i <= 300; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
JD8_BlitCK(200, 155, gfx, 0, creu, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_3[minim((i div 5),fr3-1)],15,15,200,150);
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_3[minim(i / 5, fr3 - 1)], 30, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// INTERROGANT }
|
||||
|
||||
for (int i = 0; i <= 100; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
JD8_BlitCK(200, 155, gfx, 0, creu, 15, 15, 255);
|
||||
// Put_sprite(from,where,interrogant,15,15,200,134);
|
||||
JD8_BlitCK(200, 134, gfx, 0, interrogant, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_3[fr3-1],15,15,200,150);
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_3[fr3 - 1], 30, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// deixa caure el MAPA i SOMBRA }
|
||||
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
JD8_BlitCK(200, 155, gfx, 0, creu, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_7[minim((i div 5),fr7-1)],15,15,200,150);
|
||||
if (minim(i / 5, fr7 - 1) <= 13) {
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_7[minim(i / 5, fr7 - 1)], 75, 15, 15, 255);
|
||||
} else {
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_7[minim(i / 5, fr7 - 1)], 105, 15, 15, 255);
|
||||
}
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// SOMBRA i PEDRA }
|
||||
|
||||
for (int i = 0; i <= 75; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
JD8_BlitCK(200, 155, gfx, 0, creu, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_7[fr7-1],15,15,200,150);
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_7[fr7 - 1], 105, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_8[0],15,15,200,i*2);
|
||||
JD8_BlitCK(200, i * 2, gfx, fr_ani_8[0], 75, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// trencar PEDRA }
|
||||
|
||||
for (int i = 0; i <= 19; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
JD8_BlitCK(200, 155, gfx, 0, creu, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_8[i div 10],15,15,200,150);
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_8[i / 10], 75, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// FINAL }
|
||||
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
JD8_BlitCK(200, 155, gfx, 0, creu, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_8[1],15,15,200,150);
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_8[1], 75, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_8[2],15,15,185,150);
|
||||
JD8_BlitCK(185, 150, gfx, fr_ani_8[2], 75, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_8[3],15,15,215,150);
|
||||
JD8_BlitCK(215, 150, gfx, fr_ani_8[3], 75, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// camina cap a la DRETA }
|
||||
for (int i = 0; i <= 145; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_1[(i div 5) mod fr1],15,15,i,150);
|
||||
JD8_BlitCK(i, 150, gfx, fr_ani_1[(i / 5) % fr1], 0, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_6[(i div 10) mod fr6],15,15,304-i,150);
|
||||
JD8_BlitCK(304 - i, 150, gfx, fr_ani_6[(i / 10) % fr6], 60, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// els dos quets }
|
||||
|
||||
for (int i = 0; i <= 100; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_1[1],15,15,145,150);
|
||||
JD8_BlitCK(145, 150, gfx, fr_ani_1[1], 0, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_6[1],15,15,160,150);
|
||||
JD8_BlitCK(160, 150, gfx, fr_ani_6[1], 60, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// aparicio altaveu }
|
||||
|
||||
for (int i = 0; i <= 50; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_11[(i div 10) mod 2],15,15,125,150);
|
||||
JD8_BlitCK(125, 150, gfx, fr_ani_11[(i / 10) % 2], 90, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_1[1],15,15,145,150);
|
||||
JD8_BlitCK(145, 150, gfx, fr_ani_1[1], 0, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_6[1],15,15,160,150);
|
||||
JD8_BlitCK(160, 150, gfx, fr_ani_6[1], 60, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// BALL }
|
||||
|
||||
for (int i = 0; i <= 800; i++) {
|
||||
JD8_ClearScreen(0);
|
||||
drawIntroWordmark(gfx);
|
||||
// Put_sprite(from,where,fr_ani_9[(i div 10) mod fr9],15,15,145,150);
|
||||
JD8_BlitCK(145, 150, gfx, fr_ani_9[(i / 10) % fr9], 120, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_10[(i div 10) mod fr10],15,15,160,150);
|
||||
JD8_BlitCK(160, 150, gfx, fr_ani_10[(i / 10) % fr10], 135, 15, 15, 255);
|
||||
// Put_sprite(from,where,fr_ani_11[((i div 5) mod 4)+2],15,15,125,150);
|
||||
JD8_BlitCK(125, 150, gfx, fr_ani_11[((i / 5) % 4) + 2], 90, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
if (wait_frame_or_skip()) {
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
}
|
||||
|
||||
// doIntroNewLogo() — migrat a scenes::IntroNewLogoScene (source/scenes/intro_new_logo_scene.cpp)
|
||||
|
||||
// doMenu() — migrat a scenes::MenuScene (source/scenes/menu_scene.cpp)
|
||||
|
||||
// doSlides() — migrat a scenes::SlidesScene (source/scenes/slides_scene.cpp)
|
||||
|
||||
// doBanner() — migrat a scenes::BannerScene (source/scenes/banner_scene.cpp)
|
||||
|
||||
// doSecreta() — migrat a scenes::SecretaScene (source/scenes/secreta_scene.cpp)
|
||||
|
||||
// doCredits() — migrat a scenes::CreditsScene (source/scenes/credits_scene.cpp)
|
||||
|
||||
// doMort() — migrat a scenes::MortScene (source/scenes/mort_scene.cpp)
|
||||
|
||||
@@ -11,21 +11,7 @@ class ModuleSequence {
|
||||
|
||||
int Go();
|
||||
|
||||
// Exposat temporalment (public) fins al Step 9 del pla de migració,
|
||||
// quan `doIntroSprites` es reescriurà com a scenes::IntroSpritesScene.
|
||||
// Mentrestant, scenes::IntroNewLogoScene el crida al final del seu
|
||||
// ciclo per delegar la part de les animacions de sprites.
|
||||
void doIntroSprites(Uint8* gfx);
|
||||
|
||||
private:
|
||||
// doIntro() → migrat a scenes::IntroScene
|
||||
// doIntroNewLogo() → migrat a scenes::IntroNewLogoScene
|
||||
// doMenu() → migrat a scenes::MenuScene
|
||||
// doSlides() → migrat a scenes::SlidesScene
|
||||
// doBanner() → migrat a scenes::BannerScene
|
||||
// doSecreta() → migrat a scenes::SecretaScene
|
||||
// doCredits() → migrat a scenes::CreditsScene
|
||||
// doMort() → migrat a scenes::MortScene
|
||||
|
||||
int contador;
|
||||
// Totes les doX() han sigut migrades a escenes dins source/scenes/.
|
||||
// El Step 10 del pla eliminarà ModuleSequence sencer, inclòs Go(),
|
||||
// quan el gameFiberEntry deixe de cridar-lo com a fallback.
|
||||
};
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "core/jail/jdraw8.hpp"
|
||||
#include "core/jail/jinput.hpp"
|
||||
#include "game/info.hpp"
|
||||
#include "game/modulesequence.hpp"
|
||||
#include "scenes/scene_utils.hpp"
|
||||
|
||||
namespace {
|
||||
@@ -98,7 +97,7 @@ void IntroNewLogoScene::render() {
|
||||
LETTER_WIDTHS[8], LOGO_HEIGHT);
|
||||
break;
|
||||
|
||||
case Phase::Delegate:
|
||||
case Phase::Sprites:
|
||||
case Phase::Done:
|
||||
break;
|
||||
}
|
||||
@@ -122,10 +121,10 @@ void IntroNewLogoScene::advancePaletteCycle() {
|
||||
|
||||
void IntroNewLogoScene::tick(int delta_ms) {
|
||||
// Qualsevol tecla durant el revelat o el ciclo de paleta salta
|
||||
// TOTA la intro (inclou saltar doIntroSprites). Aquest era el
|
||||
// comportament del vell `doIntroNewLogo`: a cada `waitTick()`
|
||||
// retornava abans de cridar `doIntroSprites`.
|
||||
if (phase_ != Phase::Delegate && phase_ != Phase::Done && JI_AnyKey()) {
|
||||
// TOTA la intro (inclou saltar la fase de sprites). Durant Sprites
|
||||
// deixem que la sub-escena gestione el seu propi skip (que a més
|
||||
// respecta la fase "final" no skippable de la variant 0).
|
||||
if (phase_ != Phase::Sprites && phase_ != Phase::Done && JI_AnyKey()) {
|
||||
info::ctx.num_piramide = 0;
|
||||
phase_ = Phase::Done;
|
||||
return;
|
||||
@@ -189,28 +188,27 @@ void IntroNewLogoScene::tick(int delta_ms) {
|
||||
phase_acc_ms_ += delta_ms;
|
||||
render();
|
||||
if (phase_acc_ms_ >= FINAL_WAIT_MS) {
|
||||
phase_ = Phase::Delegate;
|
||||
phase_ = Phase::Sprites;
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::Delegate: {
|
||||
// Delegació temporal al codi legacy: crea un ModuleSequence
|
||||
// instància i li crida `doIntroSprites(gfx)`. La funció
|
||||
// legacy *sempre* allibera `gfx` ella mateixa (al final o en
|
||||
// els paths de skip amb JI_AnyKey), així que necessitem
|
||||
// transferir-li ownership via `release()` per evitar un
|
||||
// double free al destructor de SurfaceHandle. Step 9
|
||||
// d'aquesta migració la reescriurà com a IntroSpritesScene
|
||||
// i la delegació desapareixerà.
|
||||
ModuleSequence legacy;
|
||||
legacy.doIntroSprites(gfx_.release());
|
||||
// El vell `Go()` post-switch feia `num_piramide = 0` per a
|
||||
// passar al menú. Ho reproduïm ací — si no, el while extern
|
||||
// del fiber tornaria a crear IntroNewLogoScene infinitament.
|
||||
info::ctx.num_piramide = 0;
|
||||
phase_ = Phase::Done;
|
||||
case Phase::Sprites:
|
||||
// Sub-escena construïda al primer tick. Transferim el gfx_
|
||||
// per move — la sub-escena se n'ocupa fins que es destruix.
|
||||
// Cada tick successiu delega l'animació dels sprites.
|
||||
if (!sprites_scene_) {
|
||||
sprites_scene_ = std::make_unique<IntroSpritesScene>(std::move(gfx_));
|
||||
sprites_scene_->onEnter();
|
||||
}
|
||||
sprites_scene_->tick(delta_ms);
|
||||
if (sprites_scene_->done()) {
|
||||
// El vell `Go()` post-switch feia `num_piramide = 0`
|
||||
// per passar al menú. Sense açò el while del fiber
|
||||
// tornaria a crear IntroNewLogoScene infinitament.
|
||||
info::ctx.num_piramide = 0;
|
||||
phase_ = Phase::Done;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Phase::Done:
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "core/jail/jdraw8.hpp"
|
||||
#include "scenes/intro_sprites_scene.hpp"
|
||||
#include "scenes/scene.hpp"
|
||||
#include "scenes/surface_handle.hpp"
|
||||
|
||||
@@ -17,10 +20,10 @@ namespace scenes {
|
||||
// 3. Logo complet amb cursor fix 200 ms.
|
||||
// 4. Cicle de paleta de 256 passos modificant índexs 16–31 cada 20 ms.
|
||||
// 5. Espera final 20 ms.
|
||||
// 6. Delega a la funció legacy `ModuleSequence::doIntroSprites(gfx)`
|
||||
// (que s'executa dins del mateix fiber i fa els seus propis Flips
|
||||
// cooperatius). Aquesta delegació desapareixerà al Step 9 del pla,
|
||||
// quan `doIntroSprites` es reescriga com a `IntroSpritesScene`.
|
||||
// 6. Transfereix el gfx_ a una `IntroSpritesScene` com a sub-escena
|
||||
// i li delega els ticks fins que acaba (anima el prota + momia +
|
||||
// mapa, amb 3 variants aleatòries). En acabar, setzea num_piramide
|
||||
// = 0 per passar al menú.
|
||||
//
|
||||
// Registrada al SceneRegistry amb state_key = 255, amb una factory
|
||||
// condicional: només s'activa si `Options::game.use_new_logo == true`.
|
||||
@@ -43,7 +46,7 @@ class IntroNewLogoScene : public Scene {
|
||||
FullLogoFlash, // logo complet + cursor, 200 ms
|
||||
PaletteCycle, // 256 passos × 20 ms modificant paleta
|
||||
FinalWait, // 20 ms final
|
||||
Delegate, // delega a doIntroSprites legacy i marca done
|
||||
Sprites, // tick delegat a IntroSpritesScene fins que acaba
|
||||
Done,
|
||||
};
|
||||
|
||||
@@ -53,6 +56,7 @@ class IntroNewLogoScene : public Scene {
|
||||
SurfaceHandle gfx_;
|
||||
SurfaceHandle cursor_surf_;
|
||||
JD8_Palette pal_{nullptr}; // propietat transferida a main_palette via SetScreenPalette
|
||||
std::unique_ptr<IntroSpritesScene> sprites_scene_;
|
||||
|
||||
Phase phase_{Phase::Initial};
|
||||
int phase_acc_ms_{0};
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "core/jail/jdraw8.hpp"
|
||||
#include "core/jail/jinput.hpp"
|
||||
#include "game/info.hpp"
|
||||
#include "game/modulesequence.hpp"
|
||||
#include "scenes/scene_utils.hpp"
|
||||
|
||||
namespace {
|
||||
@@ -110,7 +109,7 @@ void IntroScene::render() {
|
||||
drawWordmark(gfx_);
|
||||
break;
|
||||
|
||||
case Phase::Delegate:
|
||||
case Phase::Sprites:
|
||||
case Phase::Done:
|
||||
break;
|
||||
}
|
||||
@@ -134,12 +133,11 @@ void IntroScene::advancePaletteCycle() {
|
||||
}
|
||||
|
||||
void IntroScene::tick(int delta_ms) {
|
||||
// Qualsevol tecla durant el revelat/paleta salta TOTA la intro
|
||||
// (inclou saltar doIntroSprites). El vell `doIntro` tornava abans
|
||||
// de cridar doIntroSprites quan `wait_frame_or_skip` detectava una
|
||||
// tecla. Durant `Delegate` deixem que doIntroSprites gestione el
|
||||
// seu propi skip internament.
|
||||
if (phase_ != Phase::Delegate && phase_ != Phase::Done && JI_AnyKey()) {
|
||||
// Qualsevol tecla durant revelat/paleta salta TOTA la intro
|
||||
// (inclou saltar la fase de sprites). Durant Sprites deixem que
|
||||
// la sub-escena gestione el seu propi skip internament, que a més
|
||||
// respecta la fase "final" no skippable de la variant 0.
|
||||
if (phase_ != Phase::Sprites && phase_ != Phase::Done && JI_AnyKey()) {
|
||||
info::ctx.num_piramide = 0;
|
||||
phase_ = Phase::Done;
|
||||
return;
|
||||
@@ -189,26 +187,28 @@ void IntroScene::tick(int delta_ms) {
|
||||
phase_acc_ms_ += delta_ms;
|
||||
render();
|
||||
if (phase_acc_ms_ >= FINAL_WAIT_MS) {
|
||||
phase_ = Phase::Delegate;
|
||||
phase_ = Phase::Sprites;
|
||||
}
|
||||
break;
|
||||
|
||||
case Phase::Delegate: {
|
||||
// Delegació temporal al codi legacy. La funció legacy sempre
|
||||
// allibera `gfx` ella mateixa (al final i als paths de skip
|
||||
// amb JI_AnyKey), així que transferim ownership via release()
|
||||
// per evitar double free al destructor de SurfaceHandle.
|
||||
// Step 9 reescriurà doIntroSprites com a IntroSpritesScene i
|
||||
// aquesta delegació desapareixerà.
|
||||
ModuleSequence legacy;
|
||||
legacy.doIntroSprites(gfx_.release());
|
||||
// El vell `Go()` post-switch feia `num_piramide = 0` per
|
||||
// passar al menú. Replicat ací: si no, el while del fiber
|
||||
// tornaria a crear IntroScene infinitament.
|
||||
info::ctx.num_piramide = 0;
|
||||
phase_ = Phase::Done;
|
||||
case Phase::Sprites:
|
||||
// Sub-escena construïda al vol al primer tick d'aquesta fase.
|
||||
// Transferim el gfx_ per move — la sub-escena se n'ocupa
|
||||
// fins que es destruix. Una vegada feta, els ticks delegats
|
||||
// avancen l'animació dels sprites.
|
||||
if (!sprites_scene_) {
|
||||
sprites_scene_ = std::make_unique<IntroSpritesScene>(std::move(gfx_));
|
||||
sprites_scene_->onEnter();
|
||||
}
|
||||
sprites_scene_->tick(delta_ms);
|
||||
if (sprites_scene_->done()) {
|
||||
// Equivalent al vell `Go()` post-switch: passem al menú.
|
||||
// Sense açò el while del fiber tornaria a crear IntroScene
|
||||
// infinitament amb num_piramide encara a 255.
|
||||
info::ctx.num_piramide = 0;
|
||||
phase_ = Phase::Done;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Phase::Done:
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "core/jail/jdraw8.hpp"
|
||||
#include "scenes/intro_sprites_scene.hpp"
|
||||
#include "scenes/scene.hpp"
|
||||
#include "scenes/surface_handle.hpp"
|
||||
|
||||
@@ -20,9 +23,10 @@ namespace scenes {
|
||||
// per generar els parpelleigs finals.
|
||||
// 3. Cicle de paleta: 256 passos × 20 ms modificant els índexs 16..31.
|
||||
// 4. Espera final 200 ms.
|
||||
// 5. Delega a `ModuleSequence::doIntroSprites(gfx)` (temporal — Step 9
|
||||
// del pla la reescriurà com a IntroSpritesScene i la delegació
|
||||
// desapareixerà).
|
||||
// 5. Transfereix el gfx_ a una `IntroSpritesScene` com a sub-escena
|
||||
// i li delega els ticks fins que acaba (anima el prota + momia +
|
||||
// mapa, amb 3 variants aleatòries). En acabar, setzea num_piramide
|
||||
// = 0 per passar al menú.
|
||||
//
|
||||
// Registrada al SceneRegistry amb state_key = 255: la mateixa factory que
|
||||
// per a IntroNewLogoScene, però retornada quan `use_new_logo == false`.
|
||||
@@ -41,8 +45,8 @@ class IntroScene : public Scene {
|
||||
InitialWait, // 1000 ms pantalla negra
|
||||
Reveal, // 15 passos del wordmark
|
||||
PaletteCycle, // 256 × 20 ms mutant pal[16..31]
|
||||
FinalWait, // 200 ms abans de delegar
|
||||
Delegate, // crida ModuleSequence::doIntroSprites (Step 9 elimina)
|
||||
FinalWait, // 200 ms abans de la sub-escena de sprites
|
||||
Sprites, // tick delegat a IntroSpritesScene fins que acaba
|
||||
Done,
|
||||
};
|
||||
|
||||
@@ -51,6 +55,7 @@ class IntroScene : public Scene {
|
||||
|
||||
SurfaceHandle gfx_;
|
||||
JD8_Palette pal_{nullptr}; // propietat transferida a main_palette via SetScreenPalette
|
||||
std::unique_ptr<IntroSpritesScene> sprites_scene_;
|
||||
|
||||
Phase phase_{Phase::InitialWait};
|
||||
int phase_acc_ms_{0};
|
||||
|
||||
346
source/scenes/intro_sprites_scene.cpp
Normal file
346
source/scenes/intro_sprites_scene.cpp
Normal file
@@ -0,0 +1,346 @@
|
||||
#include "scenes/intro_sprites_scene.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "core/jail/jdraw8.hpp"
|
||||
#include "core/jail/jinput.hpp"
|
||||
#include "game/options.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
// Duració d'un pas. El vell doIntroSprites feia JG_SetUpdateTicks(20);
|
||||
// cada iteració del seu for (i) consumia un tick de 20 ms.
|
||||
constexpr int TICK_MS = 20;
|
||||
|
||||
// Taules de frames. Ubicacions de cada sprite dins el gfx de la intro
|
||||
// (logo.gif o logo/logo_new.gif — el layout de sprites és el mateix).
|
||||
// Cada sprite ocupa 15×15 px, disposats horitzontalment per fila.
|
||||
// Els valors són els offsets x (la y la posa l'invocador al src_y).
|
||||
// Derivats dels `fr_ani_N[i] = ...` del vell doIntroSprites.
|
||||
constexpr Uint16 fr1[] = {0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180}; // camina dreta (y=0)
|
||||
constexpr Uint16 fr2[] = {0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180}; // camina esquerra (y=15)
|
||||
constexpr Uint16 fr3[] = {0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150}; // trau mapa dreta (y=30)
|
||||
constexpr Uint16 fr4[] = {0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150}; // trau mapa esquerra (y=45)
|
||||
constexpr Uint16 fr5[] = {165, 180, 195, 210, 225, 240, 255, 270, 285, 300,
|
||||
300, 285, 270, 255, 240, 225, 210, 195, 180, 165}; // bot de susto (y=45, mirror)
|
||||
constexpr Uint16 fr6[] = {0, 15, 30, 45, 60, 75, 90, 105}; // momia (y=60)
|
||||
constexpr Uint16 fr7[] = {75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, // paper (y=75, idx 0..13)
|
||||
0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210}; // sombra (y=105, idx 14..28)
|
||||
constexpr Uint16 fr8[] = {15, 30, 45, 60}; // pedra (y=75)
|
||||
constexpr Uint16 fr9[] = {0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225}; // prota ball (y=120)
|
||||
constexpr Uint16 fr10[] = {0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225}; // momia ball (y=135)
|
||||
constexpr Uint16 fr11[] = {15, 30, 45, 60, 75, 60}; // altaveu (y=90, [5]=[3] pel loop de 4)
|
||||
|
||||
constexpr Uint16 CREU = 75; // src_y de la creu (overlay)
|
||||
constexpr Uint16 INTERROGANT = 90; // src_y del signe d'interrogant
|
||||
|
||||
// Equivalent de la funció `drawIntroWordmark` de modulesequence.cpp.
|
||||
// Branqueja segons use_new_logo perquè la mateixa sub-escena es
|
||||
// reutilitza des de IntroScene (logo vell) i IntroNewLogoScene (logo
|
||||
// nou) amb arxius diferents però mateix layout de sprites.
|
||||
void drawWordmark(JD8_Surface gfx) {
|
||||
if (Options::game.use_new_logo) {
|
||||
JD8_Blit(60, 78, gfx, 60, 158, 188, 28);
|
||||
} else {
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
}
|
||||
}
|
||||
|
||||
using RenderFn = void (*)(JD8_Surface, int);
|
||||
|
||||
// Una fase — rang [start_i..end_i] inclusive (direcció implícita per
|
||||
// signe), funció de render, i flag d'skippable. Totes les fases actuals
|
||||
// són skippables; el flag es conserva per si alguna futura ha de ser
|
||||
// no interrompuda (p.ex. un logo fatídic que cal veure sencer).
|
||||
struct SpritePhase {
|
||||
int start_i;
|
||||
int end_i;
|
||||
RenderFn render;
|
||||
bool skippable;
|
||||
};
|
||||
|
||||
// =========================================================================
|
||||
// Variant 0 — Interrogant / Momia
|
||||
// =========================================================================
|
||||
|
||||
void v0_walk_right(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(i, 150, gfx, fr1[(i / 5) % 13], 0, 15, 15, 0);
|
||||
}
|
||||
|
||||
void v0_pull_map_right(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(200, 150, gfx, fr3[std::min(i / 5, 10)], 30, 15, 15, 0);
|
||||
}
|
||||
|
||||
void v0_walk_left_to_80(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(i, 150, gfx, fr2[(i / 5) % 13], 15, 15, 15, 0);
|
||||
}
|
||||
|
||||
void v0_pull_map_left(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(80, 150, gfx, fr4[std::min(i / 5, 10)], 45, 15, 15, 0);
|
||||
}
|
||||
|
||||
void v0_momia_left(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(i, 150, gfx, fr6[(i / 5) % 8], 60, 15, 15, 0);
|
||||
JD8_BlitCK(80, 150, gfx, fr4[10], 45, 15, 15, 0);
|
||||
}
|
||||
|
||||
void v0_turn(JD8_Surface gfx, int /*i*/) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(80, 150, gfx, fr1[1], 0, 15, 15, 0);
|
||||
JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0);
|
||||
JD8_BlitCK(80, 133, gfx, 0, INTERROGANT, 15, 15, 0);
|
||||
}
|
||||
|
||||
void v0_jump1(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(80, 150 - ((i % 50) / 5), gfx, fr5[std::min(i / 5, 19)], 45, 15, 15, 0);
|
||||
JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0);
|
||||
}
|
||||
|
||||
void v0_jump2(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(80, 140 + ((i % 50) / 5), gfx, fr5[std::min(i / 5, 19)], 45, 15, 15, 0);
|
||||
JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0);
|
||||
}
|
||||
|
||||
void v0_walk_final(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(i, 150, gfx, fr2[(i / 5) % 13], 15, 15, 15, 0);
|
||||
JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0);
|
||||
}
|
||||
|
||||
void v0_final(JD8_Surface gfx, int /*i*/) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0);
|
||||
JD8_BlitCK(95, 133, gfx, 0, INTERROGANT, 15, 15, 0);
|
||||
}
|
||||
|
||||
constexpr SpritePhase variant_0[] = {
|
||||
{0, 200, v0_walk_right, true},
|
||||
{0, 200, v0_pull_map_right, true},
|
||||
{200, 0, v0_pull_map_right, true}, // guarda el mapa (reprodueix inversament)
|
||||
{200, 80, v0_walk_left_to_80, true},
|
||||
{0, 200, v0_pull_map_left, true},
|
||||
{300, 95, v0_momia_left, true},
|
||||
{0, 50, v0_turn, true},
|
||||
{0, 49, v0_jump1, true},
|
||||
{50, 99, v0_jump2, true},
|
||||
{80, 0, v0_walk_final, true},
|
||||
{0, 150, v0_final, true},
|
||||
};
|
||||
|
||||
// =========================================================================
|
||||
// Variant 1 — Creu / Pedra
|
||||
// =========================================================================
|
||||
|
||||
void v1_walk_right(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
|
||||
JD8_BlitCK(i, 150, gfx, fr1[(i / 5) % 13], 0, 15, 15, 255);
|
||||
}
|
||||
|
||||
void v1_pull_map(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
|
||||
JD8_BlitCK(200, 150, gfx, fr3[std::min(i / 5, 10)], 30, 15, 15, 255);
|
||||
}
|
||||
|
||||
void v1_interrogant(JD8_Surface gfx, int /*i*/) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
|
||||
JD8_BlitCK(200, 134, gfx, 0, INTERROGANT, 15, 15, 255);
|
||||
JD8_BlitCK(200, 150, gfx, fr3[10], 30, 15, 15, 255);
|
||||
}
|
||||
|
||||
void v1_drop_map(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
|
||||
const int idx = std::min(i / 5, 28);
|
||||
// fr7 té 29 frames dividits en dos grups: paper (idx 0..13, src_y=75)
|
||||
// i sombra (idx 14..28, src_y=105). El vell feia una branca al bucle.
|
||||
if (idx <= 13) {
|
||||
JD8_BlitCK(200, 150, gfx, fr7[idx], 75, 15, 15, 255);
|
||||
} else {
|
||||
JD8_BlitCK(200, 150, gfx, fr7[idx], 105, 15, 15, 255);
|
||||
}
|
||||
}
|
||||
|
||||
void v1_stone_fall(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
|
||||
JD8_BlitCK(200, 150, gfx, fr7[28], 105, 15, 15, 255);
|
||||
JD8_BlitCK(200, i * 2, gfx, fr8[0], 75, 15, 15, 255);
|
||||
}
|
||||
|
||||
void v1_stone_break(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
|
||||
JD8_BlitCK(200, 150, gfx, fr8[i / 10], 75, 15, 15, 255);
|
||||
}
|
||||
|
||||
void v1_final(JD8_Surface gfx, int /*i*/) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
|
||||
JD8_BlitCK(200, 150, gfx, fr8[1], 75, 15, 15, 255);
|
||||
JD8_BlitCK(185, 150, gfx, fr8[2], 75, 15, 15, 255);
|
||||
JD8_BlitCK(215, 150, gfx, fr8[3], 75, 15, 15, 255);
|
||||
}
|
||||
|
||||
constexpr SpritePhase variant_1[] = {
|
||||
{0, 200, v1_walk_right, true},
|
||||
{0, 300, v1_pull_map, true},
|
||||
{0, 100, v1_interrogant, true},
|
||||
{0, 200, v1_drop_map, true},
|
||||
{0, 75, v1_stone_fall, true},
|
||||
{0, 19, v1_stone_break, true},
|
||||
{0, 200, v1_final, true},
|
||||
};
|
||||
|
||||
// =========================================================================
|
||||
// Variant 2 — Ball de carnaval
|
||||
// =========================================================================
|
||||
|
||||
void v2_approach(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(i, 150, gfx, fr1[(i / 5) % 13], 0, 15, 15, 255);
|
||||
JD8_BlitCK(304 - i, 150, gfx, fr6[(i / 10) % 8], 60, 15, 15, 255);
|
||||
}
|
||||
|
||||
void v2_still(JD8_Surface gfx, int /*i*/) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(145, 150, gfx, fr1[1], 0, 15, 15, 255);
|
||||
JD8_BlitCK(160, 150, gfx, fr6[1], 60, 15, 15, 255);
|
||||
}
|
||||
|
||||
void v2_horn(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(125, 150, gfx, fr11[(i / 10) % 2], 90, 15, 15, 255);
|
||||
JD8_BlitCK(145, 150, gfx, fr1[1], 0, 15, 15, 255);
|
||||
JD8_BlitCK(160, 150, gfx, fr6[1], 60, 15, 15, 255);
|
||||
}
|
||||
|
||||
void v2_ball(JD8_Surface gfx, int i) {
|
||||
JD8_ClearScreen(0);
|
||||
drawWordmark(gfx);
|
||||
JD8_BlitCK(145, 150, gfx, fr9[(i / 10) % 16], 120, 15, 15, 255);
|
||||
JD8_BlitCK(160, 150, gfx, fr10[(i / 10) % 16], 135, 15, 15, 255);
|
||||
JD8_BlitCK(125, 150, gfx, fr11[((i / 5) % 4) + 2], 90, 15, 15, 255);
|
||||
}
|
||||
|
||||
constexpr SpritePhase variant_2[] = {
|
||||
{0, 145, v2_approach, true},
|
||||
{0, 100, v2_still, true},
|
||||
{0, 50, v2_horn, true},
|
||||
{0, 800, v2_ball, true},
|
||||
};
|
||||
|
||||
// =========================================================================
|
||||
// Dispatch per variant
|
||||
// =========================================================================
|
||||
|
||||
const SpritePhase* variant_table(int variant) {
|
||||
switch (variant) {
|
||||
case 0: return variant_0;
|
||||
case 1: return variant_1;
|
||||
case 2: return variant_2;
|
||||
}
|
||||
return variant_0;
|
||||
}
|
||||
|
||||
int variant_length(int variant) {
|
||||
switch (variant) {
|
||||
case 0: return sizeof(variant_0) / sizeof(variant_0[0]);
|
||||
case 1: return sizeof(variant_1) / sizeof(variant_1[0]);
|
||||
case 2: return sizeof(variant_2) / sizeof(variant_2[0]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int phase_step_count(const SpritePhase& p) {
|
||||
return std::abs(p.end_i - p.start_i) + 1;
|
||||
}
|
||||
|
||||
int phase_current_i(const SpritePhase& p, int step) {
|
||||
return p.end_i >= p.start_i ? p.start_i + step : p.start_i - step;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace scenes {
|
||||
|
||||
IntroSpritesScene::IntroSpritesScene(SurfaceHandle&& gfx)
|
||||
: gfx_(std::move(gfx)) {}
|
||||
|
||||
void IntroSpritesScene::onEnter() {
|
||||
// El vell doIntroSprites feia `rand() % 3` al principi. El seed ve
|
||||
// establert per `srand(time(0))` al boot del joc (info.cpp / main),
|
||||
// així que la variant canvia entre execucions.
|
||||
variant_ = std::rand() % 3;
|
||||
phase_ = 0;
|
||||
phase_step_ = 0;
|
||||
step_acc_ms_ = 0;
|
||||
done_ = false;
|
||||
|
||||
// Renderitzem ja el primer frame (step 0 de la primera fase) perquè
|
||||
// el JD8_Flip del mini-loop del fiber el pinte al primer cicle.
|
||||
const SpritePhase* phases = variant_table(variant_);
|
||||
phases[0].render(gfx_.get(), phase_current_i(phases[0], 0));
|
||||
}
|
||||
|
||||
void IntroSpritesScene::tick(int delta_ms) {
|
||||
if (done_) return;
|
||||
|
||||
const SpritePhase* phases = variant_table(variant_);
|
||||
const int num_phases = variant_length(variant_);
|
||||
|
||||
// Skip per tecla. Durant la fase marcada com a no skippable (només
|
||||
// v0_final al vell codi) s'ignora — preserva la semàntica del vell
|
||||
// bucle final de la variant 0 que no cridava wait_frame_or_skip.
|
||||
if (phases[phase_].skippable && JI_AnyKey()) {
|
||||
done_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
step_acc_ms_ += delta_ms;
|
||||
while (step_acc_ms_ >= TICK_MS && !done_) {
|
||||
step_acc_ms_ -= TICK_MS;
|
||||
++phase_step_;
|
||||
if (phase_step_ >= phase_step_count(phases[phase_])) {
|
||||
++phase_;
|
||||
phase_step_ = 0;
|
||||
if (phase_ >= num_phases) {
|
||||
done_ = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
phases[phase_].render(gfx_.get(), phase_current_i(phases[phase_], phase_step_));
|
||||
}
|
||||
|
||||
} // namespace scenes
|
||||
43
source/scenes/intro_sprites_scene.hpp
Normal file
43
source/scenes/intro_sprites_scene.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include "scenes/scene.hpp"
|
||||
#include "scenes/surface_handle.hpp"
|
||||
|
||||
namespace scenes {
|
||||
|
||||
// Sub-escena de sprites de la intro (prota + momia + mapa + etc).
|
||||
// Reemplaça `ModuleSequence::doIntroSprites()`. No es registra al
|
||||
// SceneRegistry — es construeix com a membre de `IntroScene` o
|
||||
// `IntroNewLogoScene` quan aquestes completen el seu revelat del logo.
|
||||
// Rep el `SurfaceHandle` del gfx de la intro via move, de manera que
|
||||
// quan acabe l'escena el surface es lliberarà automàticament.
|
||||
//
|
||||
// En entrar tria una de 3 variants (`rand() % 3`): "interrogant/momia",
|
||||
// "creu/pedra" o "ball de carnaval". Cada variant té un nombre
|
||||
// diferent de fases però comparteixen el mateix motor: un comptador
|
||||
// `step` que s'incrementa cada 20 ms, amb una taula per variant que
|
||||
// mapeja (rang d'i, renderer) a cada fase. Qualsevol tecla salta
|
||||
// l'escena — el flag `skippable` per fase es manté com a mecanisme
|
||||
// per si alguna fase futura ha de ser no interrompuda (al vell codi
|
||||
// la fase "final" de la variant 0 no cridava wait_frame_or_skip, cosa
|
||||
// molt probablement un oversight: ací es tracta com a skippable).
|
||||
class IntroSpritesScene : public Scene {
|
||||
public:
|
||||
explicit IntroSpritesScene(SurfaceHandle&& gfx);
|
||||
~IntroSpritesScene() override = default;
|
||||
|
||||
void onEnter() override;
|
||||
void tick(int delta_ms) override;
|
||||
bool done() const override { return done_; }
|
||||
int nextState() const override { return 1; }
|
||||
|
||||
private:
|
||||
SurfaceHandle gfx_;
|
||||
int variant_{0}; // 0..2 — triada a onEnter() amb rand() % 3
|
||||
int phase_{0}; // índex dins la variant actual
|
||||
int phase_step_{0}; // passos consumits dins la fase actual
|
||||
int step_acc_ms_{0}; // acumulador per emetre steps de 20 ms
|
||||
bool done_{false};
|
||||
};
|
||||
|
||||
} // namespace scenes
|
||||
Reference in New Issue
Block a user